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 b7343241772 Fix copy from
b7343241772 is described below

commit b734324177277944af22483b5fed63fd6ae800fc
Author: Jinbao Chen <[email protected]>
AuthorDate: Wed Oct 29 23:52:35 2025 +0800

    Fix copy from
---
 src/backend/commands/copyfromparse.c | 10 +++++-----
 src/backend/parser/parse_utilcmd.c   |  8 ++++----
 src/backend/utils/adt/numeric.c      | 32 +-------------------------------
 src/test/regress/serial_schedule     | 12 ++++++------
 4 files changed, 16 insertions(+), 46 deletions(-)

diff --git a/src/backend/commands/copyfromparse.c 
b/src/backend/commands/copyfromparse.c
index 75693da9a92..657348119c4 100644
--- a/src/backend/commands/copyfromparse.c
+++ b/src/backend/commands/copyfromparse.c
@@ -800,9 +800,9 @@ NextCopyFromRawFieldsX(CopyFromState cstate, char 
***fields, int *nfields,
                        int                     fldnum;
 
                        if (cstate->opts.csv_mode)
-                               fldct = CopyReadAttributesCSV(cstate, 
stop_processing_at_field);
+                               fldct = CopyReadAttributesCSV(cstate, -1);
                        else
-                               fldct = CopyReadAttributesText(cstate, 
stop_processing_at_field);
+                               fldct = CopyReadAttributesText(cstate, -1);
 
                        if (fldct != list_length(cstate->attnumlist))
                                ereport(ERROR,
@@ -855,9 +855,9 @@ NextCopyFromRawFieldsX(CopyFromState cstate, char 
***fields, int *nfields,
 
        /* Parse the line into de-escaped field values */
        if (cstate->opts.csv_mode)
-               fldct = CopyReadAttributesCSV(cstate, -1);
+               fldct = CopyReadAttributesCSV(cstate, stop_processing_at_field);
        else
-               fldct = CopyReadAttributesText(cstate, -1);
+               fldct = CopyReadAttributesText(cstate, 
stop_processing_at_field);
 
        *fields = cstate->raw_fields;
        *nfields = fldct;
@@ -1004,7 +1004,7 @@ NextCopyFromX(CopyFromState cstate, ExprContext *econtext,
                 * when all fields are processed in the QD.
                 */
                if (fldct > attr_count)
-                       ereport(ERROR,
+                       ereport(PANIC,
                                        (errcode(ERRCODE_BAD_COPY_FILE_FORMAT),
                                                        errmsg("extra data 
after last expected column")));
 
diff --git a/src/backend/parser/parse_utilcmd.c 
b/src/backend/parser/parse_utilcmd.c
index 74a7ef940f9..4b281c1e1f9 100644
--- a/src/backend/parser/parse_utilcmd.c
+++ b/src/backend/parser/parse_utilcmd.c
@@ -3091,7 +3091,7 @@ transformDistributedBy(ParseState *pstate,
 
                foreach(dk, distrkeys)
                {
-                       char       *distcolname = strVal(lfirst(dk));
+                       IndexElem  *distcolname = lfirst(dk);
                        ListCell   *ip;
                        bool            found = false;
 
@@ -3102,7 +3102,7 @@ transformDistributedBy(ParseState *pstate,
                                if (!iparam->name)
                                        elog(ERROR, "PRIMARY KEY on an 
expression index not supported");
 
-                               if (strcmp(iparam->name, distcolname) == 0)
+                               if (strcmp(iparam->name, distcolname->name) == 
0)
                                {
                                        found = true;
                                        break;
@@ -3131,7 +3131,7 @@ transformDistributedBy(ParseState *pstate,
 
                foreach(dk, distrkeys)
                {
-                       char       *distcolname = strVal(lfirst(dk));
+                       IndexElem *distcolname = lfirst(dk);
                        ListCell   *ip;
                        bool            found = false;
 
@@ -3143,7 +3143,7 @@ transformDistributedBy(ParseState *pstate,
                                if (!iparam->name)
                                        elog(ERROR, "UNIQUE constraint on an 
expression index not supported");
 
-                               if (strcmp(iparam->name, distcolname) == 0)
+                               if (strcmp(iparam->name, distcolname->name) == 
0)
                                {
                                        found = true;
                                        break;
diff --git a/src/backend/utils/adt/numeric.c b/src/backend/utils/adt/numeric.c
index 5ed2479855f..0d9277a843d 100644
--- a/src/backend/utils/adt/numeric.c
+++ b/src/backend/utils/adt/numeric.c
@@ -3837,6 +3837,7 @@ numeric_power(PG_FUNCTION_ARGS)
                 */
                if (sign2 == 0)
                        PG_RETURN_NUMERIC(make_numeric_result(&const_one));
+
                /*
                 * For any odd integer value of y > 0, if x is [-]0, [-]0 shall 
be
                 * returned.  For y > 0 and not an odd integer, if x is [-]0, 
+0 shall
@@ -3846,7 +3847,6 @@ numeric_power(PG_FUNCTION_ARGS)
                if (sign1 == 0 && sign2 > 0)
                        PG_RETURN_NUMERIC(make_numeric_result(&const_zero));
 
-
                /*
                 * If x is -1, and y is [-]Inf, 1.0 shall be returned.
                 *
@@ -11132,36 +11132,6 @@ power_var(const NumericVar *base, const NumericVar 
*exp, NumericVar *result)
        quick_init_var(&ln_base);
        quick_init_var(&ln_num);
 
-       /*
-        * If base is negative, insist that exp be an integer.  The result is 
then
-        * positive if exp is even and negative if exp is odd.
-        */
-       if (base->sign == NUMERIC_NEG)
-       {
-               /*
-                * Check that exp is an integer.  This error code is defined by 
the
-                * SQL standard, and matches other errors in numeric_power().
-                */
-               if (exp->ndigits > 0 && exp->ndigits > exp->weight + 1)
-                       ereport(ERROR,
-                                       
(errcode(ERRCODE_INVALID_ARGUMENT_FOR_POWER_FUNCTION),
-                                        errmsg("a negative number raised to a 
non-integer power yields a complex result")));
-
-               /* Test if exp is odd or even */
-               if (exp->ndigits > 0 && exp->ndigits == exp->weight + 1 &&
-                       (exp->digits[exp->ndigits - 1] & 1))
-                       res_sign = NUMERIC_NEG;
-               else
-                       res_sign = NUMERIC_POS;
-
-               /* Then work with abs(base) below */
-               set_var_from_var(base, &abs_base);
-               abs_base.sign = NUMERIC_POS;
-               base = &abs_base;
-       }
-       else
-               res_sign = NUMERIC_POS;
-
        /*
         * If base is negative, insist that exp be an integer.  The result is 
then
         * positive if exp is even and negative if exp is odd.
diff --git a/src/test/regress/serial_schedule b/src/test/regress/serial_schedule
index f3036be1de7..230f67fe32e 100644
--- a/src/test/regress/serial_schedule
+++ b/src/test/regress/serial_schedule
@@ -10,16 +10,16 @@ test: text
 test: int2
 test: int4
 test: int8
-# test: oid
-# test: xid
+test: oid
+test: xid
 test: float4
 test: float8
 test: bit
 test: numeric
-# test: txid
-# test: uuid
-# test: enum
-# test: money
+test: txid
+test: uuid
+test: enum
+test: money
 # test: rangetypes
 # test: multirangetypes
 # test: pg_lsn


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to