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 ae7b82ad86f Fix compile error on parser
ae7b82ad86f is described below

commit ae7b82ad86fe5c73eebbac77acf1f591e4339309
Author: Jinbao Chen <[email protected]>
AuthorDate: Wed Sep 10 17:42:29 2025 +0800

    Fix compile error on parser
---
 src/backend/Makefile        |  12 +-
 src/backend/parser/gram.y   |  27 ++-
 src/include/miscadmin.h     |  20 --
 src/include/parser/kwlist.h |   1 +
 src/include/pg_config.h.in  | 119 +----------
 src/include/postgres.h      | 470 ++------------------------------------------
 src/include/varatt.h        |   8 +-
 7 files changed, 38 insertions(+), 619 deletions(-)

diff --git a/src/backend/Makefile b/src/backend/Makefile
index 3b07e9b435e..50fa0853fc7 100644
--- a/src/backend/Makefile
+++ b/src/backend/Makefile
@@ -164,16 +164,16 @@ storage/lmgr/lwlocknames.h: 
storage/lmgr/generate-lwlocknames.pl storage/lmgr/lw
        $(MAKE) -C storage/lmgr lwlocknames.h lwlocknames.c
 
 # run this unconditionally to avoid needing to know its dependencies here:
-submake-catalog-headers:
-       $(MAKE) -C catalog distprep generated-header-symlinks
+#submake-catalog-headers:
+#      $(MAKE) -C catalog distprep generated-header-symlinks
 
 # run this unconditionally to avoid needing to know its dependencies here:
-submake-nodes-headers:
-       $(MAKE) -C nodes distprep generated-header-symlinks
+#submake-nodes-headers:
+#      $(MAKE) -C nodes distprep generated-header-symlinks
 
 # run this unconditionally to avoid needing to know its dependencies here:
-submake-utils-headers:
-       $(MAKE) -C utils distprep generated-header-symlinks
+#submake-utils-headers:
+#      $(MAKE) -C utils distprep generated-header-symlinks
 
 .PHONY: submake-catalog-headers submake-nodes-headers submake-utils-headers
 
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y
index 5644ae78775..e2a309b3125 100644
--- a/src/backend/parser/gram.y
+++ b/src/backend/parser/gram.y
@@ -355,7 +355,6 @@ static void 
check_expressions_in_partition_key(PartitionSpec *spec, core_yyscan_
 
 %type <str>                    opt_single_name
 %type <list>           opt_qualified_name
-%type <boolean>                opt_concurrently
 %type <dbehavior>      opt_drop_behavior
 
 %type <node>   alter_column_default opclass_item opclass_drop alter_using
@@ -445,7 +444,7 @@ static void 
check_expressions_in_partition_key(PartitionSpec *spec, core_yyscan_
 %type <str>            OptWithLocation
 
 %type <list>   func_name handler_name qual_Op qual_all_Op subquery_Op
-                               opt_inline_handler opt_validator 
validator_clause
+                               opt_class opt_inline_handler opt_validator 
validator_clause
                                opt_collate
 
 %type <range>  qualified_name insert_target OptConstrFromTable
@@ -908,7 +907,7 @@ static void 
check_expressions_in_partition_key(PartitionSpec *spec, core_yyscan_
 
        ERRORS EVERY EXCHANGE EXPAND
 
-       FAILED_LOGIN_ATTEMPTS FIELDS FILL FORMAT
+       FAILED_LOGIN_ATTEMPTS FIELDS FILL
 
        FULLSCAN
 
@@ -995,8 +994,7 @@ static void 
check_expressions_in_partition_key(PartitionSpec *spec, core_yyscan_
 
 /* SQL/JSON related keywords */
 %nonassoc      UNIQUE JSON
-%nonassoc      KEYS OBJECT_P SCALAR VALUE_P
-%nonassoc      WITH WITHOUT
+%nonassoc      KEYS SCALAR
 
 /*
  * To support target_el without AS, it used to be necessary to assign IDENT an
@@ -4046,15 +4044,6 @@ alter_table_cmd:
                                        n->newowner = $3;
                                        $$ = (Node *) n;
                                }
-                       /* ALTER TABLE <name> SET ACCESS METHOD <amname> */
-                       | SET ACCESS METHOD name
-                               {
-                                       AlterTableCmd *n = 
makeNode(AlterTableCmd);
-
-                                       n->subtype = AT_SetAccessMethod;
-                                       n->name = $4;
-                                       $$ = (Node *) n;
-                               }
                        /* ALTER TABLE <name> SET ACCESS METHOD <amname> WITH 
(<reloptions>) */
                        | SET ACCESS METHOD name OptWith
                                {
@@ -4067,9 +4056,9 @@ alter_table_cmd:
                                         * clause such as 'appendonly' or 
'appendoptimized', it has
                                         * to match with the AM name.
                                         */
-                                       if (witham) 
+                                       if (witham)
                                        {
-                                               if (strlen(witham) != 
strlen(n->name) || 
+                                               if (strlen(witham) != 
strlen(n->name) ||
                                                        strcmp(n->name, witham) 
!= 0)
                                                        ereport(ERROR,
                                                                        
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
@@ -11709,6 +11698,10 @@ opt_collate: COLLATE any_name                          
                { $$ = $2; }
                        | /*EMPTY*/                                             
                { $$ = NIL; }
                ;
 
+opt_class:     any_name                                                        
        { $$ = $1; }
+                       | /*EMPTY*/                                             
                { $$ = NIL; }
+               ;
+
 
 opt_asc_desc: ASC                                                      { $$ = 
SORTBY_ASC; }
                        | DESC                                                  
{ $$ = SORTBY_DESC; }
@@ -21066,6 +21059,7 @@ unreserved_keyword:
                        | ALSO
                        | ALTER
                        | ALWAYS
+                       | ASENSITIVE
                        | ASSERTION
                        | ASSIGNMENT
                        | AT
@@ -21341,6 +21335,7 @@ unreserved_keyword:
                        | ROWS
                        | RULE
                        | SAVEPOINT
+                       | SCALAR
                        | SCHEDULE
                        | SCHEMA
                        | SCHEMAS
diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h
index e4d7aa3ba03..87018b67077 100644
--- a/src/include/miscadmin.h
+++ b/src/include/miscadmin.h
@@ -428,13 +428,10 @@ typedef enum BackendType
        B_BG_WORKER,
        B_BG_WRITER,
        B_CHECKPOINTER,
-<<<<<<< HEAD
        B_LOGIN_MONITOR,
        B_LOGIN_MONITOR_WORKER,
-=======
        B_LOGGER,
        B_STANDALONE_BACKEND,
->>>>>>> REL_16_9
        B_STARTUP,
        B_WAL_RECEIVER,
        B_WAL_SENDER,
@@ -458,16 +455,12 @@ extern char *GetUserNameFromId(Oid roleid, bool noerr);
 extern Oid     GetUserId(void);
 extern Oid     GetOuterUserId(void);
 extern Oid     GetSessionUserId(void);
-<<<<<<< HEAD
 extern void    SetSessionUserId(Oid, bool);
-extern Oid     GetAuthenticatedUserId(void);
 extern bool IsAuthenticatedUserSuperUser(void);
-=======
 extern bool GetSessionUserIsSuperuser(void);
 extern Oid     GetAuthenticatedUserId(void);
 extern bool GetAuthenticatedUserIsSuperuser(void);
 extern void SetAuthenticatedUserId(Oid userid, bool is_superuser);
->>>>>>> REL_16_9
 extern void GetUserIdAndSecContext(Oid *userid, int *sec_context);
 extern void SetUserIdAndSecContext(Oid userid, int sec_context);
 extern bool InLocalUserIdChange(void);
@@ -480,14 +473,11 @@ extern void InitializeSessionUserIdStandalone(void);
 extern void SetSessionAuthorization(Oid userid, bool is_superuser);
 extern Oid     GetCurrentRoleId(void);
 extern void SetCurrentRoleId(Oid roleid, bool is_superuser);
-<<<<<<< HEAD
 extern Oid GetCurrentWarehouseId(void);
 extern void SetCurrentWarehouseId(Oid warehouseid);
-=======
 extern void InitializeSystemUser(const char *authn_id,
                                                                 const char 
*auth_method);
 extern const char *GetSystemUser(void);
->>>>>>> REL_16_9
 
 /* in utils/misc/superuser.c */
 extern bool superuser(void);   /* current user is superuser */
@@ -593,18 +583,11 @@ extern void BaseInit(void);
 /* in utils/init/miscinit.c */
 extern PGDLLIMPORT bool IgnoreSystemIndexes;
 extern PGDLLIMPORT bool process_shared_preload_libraries_in_progress;
-<<<<<<< HEAD
-extern bool process_shared_preload_libraries_done;
-extern char *session_preload_libraries_string;
-extern char *shared_preload_libraries_string;
-extern char *local_preload_libraries_string;
-=======
 extern PGDLLIMPORT bool process_shared_preload_libraries_done;
 extern PGDLLIMPORT bool process_shmem_requests_in_progress;
 extern PGDLLIMPORT char *session_preload_libraries_string;
 extern PGDLLIMPORT char *shared_preload_libraries_string;
 extern PGDLLIMPORT char *local_preload_libraries_string;
->>>>>>> REL_16_9
 
 extern void CreateDataDirLockFile(bool amPostmaster);
 extern void CreateSocketLockFile(const char *socketfile, bool amPostmaster,
@@ -628,10 +611,7 @@ extern void RestoreClientConnectionInfo(char *conninfo);
 
 /* in executor/nodeHash.c */
 extern size_t get_hash_memory_limit(void);
-<<<<<<< HEAD
 extern int     get_hash_mem(void);
-=======
->>>>>>> REL_16_9
 
 /*
  * In GPDB, some utility commands may execute nested in another utilities,
diff --git a/src/include/parser/kwlist.h b/src/include/parser/kwlist.h
index 663ea60ffbe..43c5db05afc 100644
--- a/src/include/parser/kwlist.h
+++ b/src/include/parser/kwlist.h
@@ -49,6 +49,7 @@ PG_KEYWORD("ao_aux_only", AO_AUX_ONLY, 
TYPE_FUNC_NAME_KEYWORD, BARE_LABEL) /* GP
 PG_KEYWORD("array", ARRAY, RESERVED_KEYWORD, AS_LABEL)
 PG_KEYWORD("as", AS, RESERVED_KEYWORD, AS_LABEL)
 PG_KEYWORD("asc", ASC, RESERVED_KEYWORD, BARE_LABEL)
+PG_KEYWORD("asensitive", ASENSITIVE, UNRESERVED_KEYWORD, BARE_LABEL)
 PG_KEYWORD("assertion", ASSERTION, UNRESERVED_KEYWORD, BARE_LABEL)
 PG_KEYWORD("assignment", ASSIGNMENT, UNRESERVED_KEYWORD, BARE_LABEL)
 PG_KEYWORD("asymmetric", ASYMMETRIC, RESERVED_KEYWORD, BARE_LABEL)
diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in
index 1a27554e7dc..c7c160b7947 100644
--- a/src/include/pg_config.h.in
+++ b/src/include/pg_config.h.in
@@ -58,7 +58,6 @@
    (--enable-thread-safety) */
 #undef ENABLE_THREAD_SAFETY
 
-<<<<<<< HEAD
 /* Define to 1 to build with fault injector. (--enable-faultinjector) */
 #undef FAULT_INJECTOR
 
@@ -79,12 +78,6 @@
    reference if 'false' (always true in GPDB) */
 #undef FLOAT8PASSBYVAL
 
-/* Define to 1 if gettimeofday() takes only 1 argument. */
-#undef GETTIMEOFDAY_1ARG
-
-#ifdef GETTIMEOFDAY_1ARG
-# define gettimeofday(a,b) gettimeofday(a)
-#endif
 
 /* Define to 1 to build ORCA in debug (GPOS_DEBUG=1) */
 #undef GPOS_DEBUG
@@ -101,8 +94,6 @@
 /* Cloudberry version as a number */
 #undef GP_VERSION_NUM
 
-=======
->>>>>>> REL_16_9
 /* Define to 1 if you have the `append_history' function. */
 #undef HAVE_APPEND_HISTORY
 
@@ -180,17 +171,6 @@
 /* Define to 1 if you have the declaration of `preadv', and to 0 if you don't.
    */
 #undef HAVE_DECL_PREADV
-<<<<<<< HEAD
-
-/* Define to 1 if you have the declaration of `pwritev', and to 0 if you
-   don't. */
-#undef HAVE_DECL_PWRITEV
-
-/* Define to 1 if you have the declaration of `RTLD_GLOBAL', and to 0 if you
-   don't. */
-#undef HAVE_DECL_RTLD_GLOBAL
-=======
->>>>>>> REL_16_9
 
 /* Define to 1 if you have the declaration of `pwritev', and to 0 if you
    don't. */
@@ -230,18 +210,10 @@
 /* Define to 1 if fseeko (and presumably ftello) exists and is declared. */
 #undef HAVE_FSEEKO
 
-<<<<<<< HEAD
-/* Define to 1 if your compiler understands __func__. */
-#undef HAVE_FUNCNAME__FUNC
-
-/* Define to 1 if your compiler understands __FUNCTION__. */
-#undef HAVE_FUNCNAME__FUNCTION
-
 /* Define to 1 if you have __sync_lock_test_and_set(int *) and friends. */
 #undef HAVE_GCC_INT_ATOMICS
 
-=======
->>>>>>> REL_16_9
+
 /* Define to 1 if you have __atomic_compare_exchange_n(int *, int *, int). */
 #undef HAVE_GCC__ATOMIC_INT32_CAS
 
@@ -310,13 +282,11 @@
 /* Define to 1 if you have the `inet_aton' function. */
 #undef HAVE_INET_ATON
 
-<<<<<<< HEAD
 /* Define to 1 if you have the `inet_ntop' function. */
 #undef HAVE_INET_NTOP
-=======
+
 /* Define to 1 if you have the `inet_pton' function. */
 #undef HAVE_INET_PTON
->>>>>>> REL_16_9
 
 /* Define to 1 if the system has the type `int64'. */
 #undef HAVE_INT64
@@ -432,18 +402,9 @@
 /* Define to 1 if you have the `mkdtemp' function. */
 #undef HAVE_MKDTEMP
 
-<<<<<<< HEAD
-/* Define to 1 if you have the <netinet/tcp.h> header file. */
-#undef HAVE_NETINET_TCP_H
-
-/* Define to 1 if you have the <net/if.h> header file. */
-#undef HAVE_NET_IF_H
-
 /* Define to 1 if you have the <numa.h> header file. */
 #undef HAVE_NUMA_H
 
-=======
->>>>>>> REL_16_9
 /* Define to 1 if you have the `OPENSSL_init_ssl' function. */
 #undef HAVE_OPENSSL_INIT_SSL
 
@@ -462,18 +423,6 @@
 /* Define to 1 if you have the `ppoll' function. */
 #undef HAVE_PPOLL
 
-<<<<<<< HEAD
-/* Define to 1 if you have the `pread' function. */
-#undef HAVE_PREAD
-
-/* Define to 1 if you have the `pstat' function. */
-#undef HAVE_PSTAT
-
-/* Define to 1 if the PS_STRINGS thing exists. */
-#undef HAVE_PS_STRINGS
-
-=======
->>>>>>> REL_16_9
 /* Define if you have POSIX threads libraries and header files. */
 #undef HAVE_PTHREAD
 
@@ -486,15 +435,6 @@
 /* Have PTHREAD_PRIO_INHERIT. */
 #undef HAVE_PTHREAD_PRIO_INHERIT
 
-<<<<<<< HEAD
-/* Define to 1 if you have the `pwrite' function. */
-#undef HAVE_PWRITE
-
-/* Define to 1 if you have the `random' function. */
-#undef HAVE_RANDOM
-
-=======
->>>>>>> REL_16_9
 /* Define to 1 if you have the <readline.h> header file. */
 #undef HAVE_READLINE_H
 
@@ -609,32 +549,9 @@
 /* Define to 1 if you have the <sys/procctl.h> header file. */
 #undef HAVE_SYS_PROCCTL_H
 
-<<<<<<< HEAD
-/* Define to 1 if you have the <sys/pstat.h> header file. */
-#undef HAVE_SYS_PSTAT_H
-
-/* Define to 1 if you have the <sys/resource.h> header file. */
-#undef HAVE_SYS_RESOURCE_H
-
-/* Define to 1 if you have the <sys/select.h> header file. */
-#undef HAVE_SYS_SELECT_H
-
-/* Define to 1 if you have the <sys/sem.h> header file. */
-#undef HAVE_SYS_SEM_H
-
-/* Define to 1 if you have the <sys/shm.h> header file. */
-#undef HAVE_SYS_SHM_H
-
 /* Define to 1 if you have the <sys/signalfd.h> header file. */
 #undef HAVE_SYS_SIGNALFD_H
 
-/* Define to 1 if you have the <sys/sockio.h> header file. */
-#undef HAVE_SYS_SOCKIO_H
-=======
-/* Define to 1 if you have the <sys/signalfd.h> header file. */
-#undef HAVE_SYS_SIGNALFD_H
->>>>>>> REL_16_9
-
 /* Define to 1 if you have the <sys/stat.h> header file. */
 #undef HAVE_SYS_STAT_H
 
@@ -696,40 +613,21 @@
 /* Define to 1 if you have the `wcstombs_l' function. */
 #undef HAVE_WCSTOMBS_L
 
-<<<<<<< HEAD
-/* Define to 1 if you have the <wctype.h> header file. */
-#undef HAVE_WCTYPE_H
-
-/* Define to 1 if you have the <winldap.h> header file. */
-#undef HAVE_WINLDAP_H
-
-
 /* Define to 1 if you have the <winsock2.h> header file. */
 #undef HAVE_WINSOCK2_H
 
-/* Define to 1 if you have the `writev' function. */
-#undef HAVE_WRITEV
-=======
-/* Define to 1 if you have the `X509_get_signature_info' function. */
-#undef HAVE_X509_GET_SIGNATURE_INFO
->>>>>>> REL_16_9
-
-
 /* Define to 1 if you have the `X509_get_signature_nid' function. */
 #undef HAVE_X509_GET_SIGNATURE_NID
 
 /* Define to 1 if the assembler supports X86_64's POPCNTQ instruction. */
 #undef HAVE_X86_64_POPCNTQ
 
-<<<<<<< HEAD
 /* Define to 1 if you have the <yaml.h> header file. */
 #undef HAVE_YAML_H
 
 /* Define to 1 if the system has the type `_Bool'. */
 #undef HAVE__BOOL
 
-=======
->>>>>>> REL_16_9
 /* Define to 1 if your compiler understands __builtin_bswap16. */
 #undef HAVE__BUILTIN_BSWAP16
 
@@ -775,18 +673,9 @@
 /* Define to 1 if your compiler understands _Static_assert. */
 #undef HAVE__STATIC_ASSERT
 
-<<<<<<< HEAD
-/* Define to 1 if you have the `__strtoll' function. */
-#undef HAVE___STRTOLL
-
-/* Define to 1 if you have the `__strtoull' function. */
-#undef HAVE___STRTOULL
-
 /* Define to 1 if you have the `etcdlib' library (-letcdlib). */
 #undef HAVE_LIBETCDLIB
 
-=======
->>>>>>> REL_16_9
 /* Define to the appropriate printf length modifier for 64-bit ints. */
 #undef INT64_MODIFIER
 
@@ -1011,11 +900,7 @@
 /* Define to select Win32-style shared memory. */
 #undef USE_WIN32_SHARED_MEMORY
 
-<<<<<<< HEAD
-/* Define to build with zstd support. (--with-zstd) */
-=======
 /* Define to 1 to build with ZSTD support. (--with-zstd) */
->>>>>>> REL_16_9
 #undef USE_ZSTD
 
 /* Define to 1 if `wcstombs_l' requires <xlocale.h>. */
diff --git a/src/include/postgres.h b/src/include/postgres.h
index 739c279b769..2fcbceba7bd 100644
--- a/src/include/postgres.h
+++ b/src/include/postgres.h
@@ -45,375 +45,9 @@
 #include "c.h"
 #include "utils/elog.h"
 #include "utils/palloc.h"
-#include "storage/itemptr.h"
 
 /* ----------------------------------------------------------------
-<<<<<<< HEAD
- *                             Section 1:      variable-length datatypes 
(TOAST support)
- * ----------------------------------------------------------------
- */
-
-/*
- * struct varatt_external is a traditional "TOAST pointer", that is, the
- * information needed to fetch a Datum stored out-of-line in a TOAST table.
- * The data is compressed if and only if the external size stored in
- * va_extinfo is less than va_rawsize - VARHDRSZ.
- *
- * This struct must not contain any padding, because we sometimes compare
- * these pointers using memcmp.
- *
- * Note that this information is stored unaligned within actual tuples, so
- * you need to memcpy from the tuple into a local struct variable before
- * you can look at these fields!  (The reason we use memcmp is to avoid
- * having to do that just to detect equality of two TOAST pointers...)
- */
-typedef struct varatt_external
-{
-       int32           va_rawsize;             /* Original data size (includes 
header) */
-       uint32          va_extinfo;             /* External saved size (without 
header) and
-                                                                * compression 
method */
-       Oid                     va_valueid;             /* Unique ID of value 
within TOAST table */
-       Oid                     va_toastrelid;  /* RelID of TOAST table 
containing it */
-}                      varatt_external;
-
-/*
- * These macros define the "saved size" portion of va_extinfo.  Its remaining
- * two high-order bits identify the compression method.
- */
-#define VARLENA_EXTSIZE_BITS   30
-#define VARLENA_EXTSIZE_MASK   ((1U << VARLENA_EXTSIZE_BITS) - 1)
-
-/*
- * struct varatt_indirect is a "TOAST pointer" representing an out-of-line
- * Datum that's stored in memory, not in an external toast relation.
- * The creator of such a Datum is entirely responsible that the referenced
- * storage survives for as long as referencing pointer Datums can exist.
- *
- * Note that just as for struct varatt_external, this struct is stored
- * unaligned within any containing tuple.
- */
-typedef struct varatt_indirect
-{
-       struct varlena *pointer;        /* Pointer to in-memory varlena */
-}                      varatt_indirect;
-
-/*
- * struct varatt_expanded is a "TOAST pointer" representing an out-of-line
- * Datum that is stored in memory, in some type-specific, not necessarily
- * physically contiguous format that is convenient for computation not
- * storage.  APIs for this, in particular the definition of struct
- * ExpandedObjectHeader, are in src/include/utils/expandeddatum.h.
- *
- * Note that just as for struct varatt_external, this struct is stored
- * unaligned within any containing tuple.
- */
-typedef struct ExpandedObjectHeader ExpandedObjectHeader;
-
-typedef struct varatt_expanded
-{
-       ExpandedObjectHeader *eohptr;
-} varatt_expanded;
-
-/*
- * Type tag for the various sorts of "TOAST pointer" datums.  The peculiar
- * value for VARTAG_ONDISK comes from a requirement for on-disk compatibility
- * with a previous notion that the tag field was the pointer datum's length.
- *
- * GPDB: In PostgreSQL VARTAG_ONDISK is set to 18 in order to match the
- * historic (VARHDRSZ_EXTERNAL + sizeof(struct varatt_external)) value of the
- * pointer datum's length. In Cloudberry VARHDRSZ_EXTERNAL is two bytes longer
- * than PostgreSQL due to extra padding in varattrib_1b_e, so VARTAG_ONDISK has
- * to be set to 20.
- */
-typedef enum vartag_external
-{
-       VARTAG_INDIRECT = 1,
-       VARTAG_EXPANDED_RO = 2,
-       VARTAG_EXPANDED_RW = 3,
-       VARTAG_ONDISK = 20,
-       VARTAG_CUSTOM = 21 /* external toast custom defined tag */
-} vartag_external;
-
-/* this test relies on the specific tag values above */
-#define VARTAG_IS_EXPANDED(tag) \
-       (((tag) & ~1) == VARTAG_EXPANDED_RO)
-
-#define VARTAG_SIZE(tag) \
-       ((tag) == VARTAG_INDIRECT ? sizeof(varatt_indirect) : \
-        VARTAG_IS_EXPANDED(tag) ? sizeof(varatt_expanded) : \
-        (tag) == VARTAG_ONDISK ? sizeof(varatt_external) : \
-        TrapMacro(true, "unrecognized TOAST vartag"))
-
-/*
- * These structs describe the header of a varlena object that may have been
- * TOASTed.  Generally, don't reference these structs directly, but use the
- * macros below.
- *
- * We use separate structs for the aligned and unaligned cases because the
- * compiler might otherwise think it could generate code that assumes
- * alignment while touching fields of a 1-byte-header varlena.
- */
-typedef union
-{
-       struct                                          /* Normal varlena 
(4-byte length) */
-       {
-               uint32          va_header;
-               char            va_data[FLEXIBLE_ARRAY_MEMBER];
-       }                       va_4byte;
-       struct                                          /* Compressed-in-line 
format */
-       {
-               uint32          va_header;
-               uint32          va_tcinfo;      /* Original data size (excludes 
header) and
-                                                                * compression 
method; see va_extinfo */
-               char            va_data[FLEXIBLE_ARRAY_MEMBER]; /* Compressed 
data */
-       }                       va_compressed;
-} varattrib_4b;
-
-typedef struct
-{
-       uint8           va_header;
-       char            va_data[FLEXIBLE_ARRAY_MEMBER]; /* Data begins here */
-} varattrib_1b;
-
-/* NOT Like Postgres! ...In GPDB, We waste a few bytes of padding */
-/* TOAST pointers are a subset of varattrib_1b with an identifying tag byte */
-typedef struct
-{
-       uint8           va_header;              /* Always 0x80  */
-       uint8           va_tag;                 /* Type of datum */
-       uint8           va_padding[2];  /*** GPDB only:  Alignment padding ***/
-       char            va_data[FLEXIBLE_ARRAY_MEMBER]; /* Type-specific data */
-} varattrib_1b_e;
-
-/*
- * Bit layouts for varlena headers: (GPDB always stores this big-endian format)
- *
- * 00xxxxxx 4-byte length word, aligned, uncompressed data (up to 1G)
- * 01xxxxxx 4-byte length word, aligned, *compressed* data (up to 1G)
- * 10000000 1-byte length word, unaligned, TOAST pointer
- * 1xxxxxxx 1-byte length word, unaligned, uncompressed data (up to 126b)
- *
- * Cloudberry differs from PostgreSQL here... In Postgres, they use different
- * macros for big-endian and little-endian machines, so the length is 
contiguous,
- * while the 4 byte lengths are stored in native endian format.
- *
- * Cloudberry stored the 4 byte varlena header in network byte order, so it 
always
- * look big-endian in the tuple.   This is a bit ugly, but changing it would 
require
- * all our customers to initdb.
- *
- * The "xxx" bits are the length field (which includes itself in all cases).
- * In the big-endian case we mask to extract the length.
- * Note that in both cases the flag bits are in the physically
- * first byte.  Also, it is not possible for a 1-byte length word to be zero;
- * this lets us disambiguate alignment padding bytes from the start of an
- * unaligned datum.  (We now *require* pad bytes to be filled with zero!)
- *
- * In TOAST pointers the va_tag field (see varattrib_1b_e) is used to discern
- * the specific type and length of the pointer datum.
- */
-
-/*
- * Endian-dependent macros.  These are considered internal --- use the
- * external macros below instead of using these directly.
- *
- * Note: IS_1B is true for external toast records but VARSIZE_1B will return 0
- * for such records. Hence you should usually check for IS_EXTERNAL before
- * checking for IS_1B.
- */
-
-#ifdef WORDS_BIGENDIAN
-
-#define VARATT_IS_4B(PTR) \
-       ((((varattrib_1b *) (PTR))->va_header & 0x80) == 0x00)
-#define VARATT_IS_4B_U(PTR) \
-       ((((varattrib_1b *) (PTR))->va_header & 0xC0) == 0x00)
-#define VARATT_IS_4B_C(PTR) \
-       ((((varattrib_1b *) (PTR))->va_header & 0xC0) == 0x40)
-#define VARATT_IS_1B(PTR) \
-       ((((varattrib_1b *) (PTR))->va_header & 0x80) == 0x80)
-#define VARATT_IS_1B_E(PTR) \
-       ((((varattrib_1b *) (PTR))->va_header) == 0x80)
-#define VARATT_NOT_PAD_BYTE(PTR) \
-       (*((uint8 *) (PTR)) != 0)
-
-/* VARSIZE_4B() should only be used on known-aligned data */
-#define VARSIZE_4B(PTR) \
-       (((varattrib_4b *) (PTR))->va_4byte.va_header & 0x3FFFFFFF)
-#define VARSIZE_1B(PTR) \
-       (((varattrib_1b *) (PTR))->va_header & 0x7F)
-#define VARTAG_1B_E(PTR) \
-       (((varattrib_1b_e *) (PTR))->va_tag)
-
-#define SET_VARSIZE_4B(PTR,len) \
-       (((varattrib_4b *) (PTR))->va_4byte.va_header = (len) & 0x3FFFFFFF)
-#define SET_VARSIZE_4B_C(PTR,len) \
-       (((varattrib_4b *) (PTR))->va_4byte.va_header = ((len) & 0x3FFFFFFF) | 
0x40000000)
-#define SET_VARSIZE_1B(PTR,len) \
-       (((varattrib_1b *) (PTR))->va_header = (len) | 0x80)
-#define SET_VARTAG_1B_E(PTR,tag) \
-       (((varattrib_1b_e *) (PTR))->va_header = 0x80, \
-        ((varattrib_1b_e *) (PTR))->va_tag = (tag))
-#define VARSIZE_TO_SHORT(PTR)   ((char)(VARSIZE(PTR)-VARHDRSZ+VARHDRSZ_SHORT) 
| 0x80)
-
-#else                                                  /* !WORDS_BIGENDIAN */
-
-#define VARATT_IS_4B(PTR) \
-       ((((varattrib_1b *) (PTR))->va_header & 0x01) == 0x00)
-#define VARATT_IS_4B_U(PTR) \
-       ((((varattrib_1b *) (PTR))->va_header & 0x03) == 0x00)
-#define VARATT_IS_4B_C(PTR) \
-       ((((varattrib_1b *) (PTR))->va_header & 0x03) == 0x02)
-#define VARATT_IS_1B(PTR) \
-       ((((varattrib_1b *) (PTR))->va_header & 0x01) == 0x01)
-#define VARATT_IS_1B_E(PTR) \
-       ((((varattrib_1b *) (PTR))->va_header) == 0x01)
-#define VARATT_NOT_PAD_BYTE(PTR) \
-       (*((uint8 *) (PTR)) != 0)
-
-/* VARSIZE_4B() should only be used on known-aligned data */
-#define VARSIZE_4B(PTR) \
-       ((((varattrib_4b *) (PTR))->va_4byte.va_header >> 2) & 0x3FFFFFFF)
-#define VARSIZE_1B(PTR) \
-       ((((varattrib_1b *) (PTR))->va_header >> 1) & 0x7F)
-#define VARTAG_1B_E(PTR) \
-       (((varattrib_1b_e *) (PTR))->va_tag)
-
-#define SET_VARSIZE_4B(PTR,len) \
-       (((varattrib_4b *) (PTR))->va_4byte.va_header = (((uint32) (len)) << 2))
-#define SET_VARSIZE_4B_C(PTR,len) \
-       (((varattrib_4b *) (PTR))->va_4byte.va_header = (((uint32) (len)) << 2) 
| 0x02)
-#define SET_VARSIZE_1B(PTR,len) \
-       (((varattrib_1b *) (PTR))->va_header = (((uint8) (len)) << 1) | 0x01)
-#define SET_VARTAG_1B_E(PTR,tag) \
-       (((varattrib_1b_e *) (PTR))->va_header = 0x01, \
-        ((varattrib_1b_e *) (PTR))->va_tag = (tag))
-#define VARSIZE_TO_SHORT(PTR)  ((char)((VARSIZE(PTR)-VARHDRSZ+VARHDRSZ_SHORT) 
<< 1) | 0x01)
-
-#endif                                                 /* WORDS_BIGENDIAN */
-
-#define VARDATA_4B(PTR)                (((varattrib_4b *) 
(PTR))->va_4byte.va_data)
-#define VARDATA_4B_C(PTR)      (((varattrib_4b *) 
(PTR))->va_compressed.va_data)
-#define VARDATA_1B(PTR)                (((varattrib_1b *) (PTR))->va_data)
-#define VARDATA_1B_E(PTR)      (((varattrib_1b_e *) (PTR))->va_data)
-
-/*
- * Externally visible TOAST macros begin here.
- */
-
-/* In Postgres, this is 2, but in GPDB, it's 4, due to padding */
-#define VARHDRSZ_EXTERNAL              offsetof(varattrib_1b_e, va_data)
-#define VARHDRSZ_COMPRESSED            offsetof(varattrib_4b, 
va_compressed.va_data)
-#define VARHDRSZ_SHORT                 offsetof(varattrib_1b, va_data)
-
-#define VARATT_SHORT_MAX               0x7F
-#define VARATT_CAN_MAKE_SHORT(PTR) \
-       (VARATT_IS_4B_U(PTR) && \
-        (VARSIZE(PTR) - VARHDRSZ + VARHDRSZ_SHORT) <= VARATT_SHORT_MAX)
-#define VARATT_CONVERTED_SHORT_SIZE(PTR) \
-       (VARSIZE(PTR) - VARHDRSZ + VARHDRSZ_SHORT)
-
-/*
- * In consumers oblivious to data alignment, call PG_DETOAST_DATUM_PACKED(),
- * VARDATA_ANY(), VARSIZE_ANY() and VARSIZE_ANY_EXHDR().  Elsewhere, call
- * PG_DETOAST_DATUM(), VARDATA() and VARSIZE().  Directly fetching an int16,
- * int32 or wider field in the struct representing the datum layout requires
- * aligned data.  memcpy() is alignment-oblivious, as are most operations on
- * datatypes, such as text, whose layout struct contains only char fields.
- *
- * Code assembling a new datum should call VARDATA() and SET_VARSIZE().
- * (Datums begin life untoasted.)
- *
- * Other macros here should usually be used only by tuple assembly/disassembly
- * code and code that specifically wants to work with still-toasted Datums.
- */
-#define VARDATA(PTR)                                           VARDATA_4B(PTR)
-#define VARSIZE(PTR)                                           VARSIZE_4B(PTR)
-
-#define VARSIZE_SHORT(PTR)                                     VARSIZE_1B(PTR)
-#define VARDATA_SHORT(PTR)                                     VARDATA_1B(PTR)
-/* Use short var-attrib */
-#define VARSIZE_TO_SHORT_D(D)                          
VARSIZE_TO_SHORT(DatumGetPointer(D))
-
-#define VARTAG_EXTERNAL(PTR)                           VARTAG_1B_E(PTR)
-#define VARSIZE_EXTERNAL(PTR)                          (VARHDRSZ_EXTERNAL + 
VARTAG_SIZE(VARTAG_EXTERNAL(PTR)))
-#define VARDATA_EXTERNAL(PTR)                          VARDATA_1B_E(PTR)
-
-#define VARATT_IS_COMPRESSED(PTR)                      VARATT_IS_4B_C(PTR)
-#define VARATT_IS_EXTERNAL(PTR)                                
VARATT_IS_1B_E(PTR)
-#define VARATT_IS_EXTERNAL_ONDISK(PTR) \
-       (VARATT_IS_EXTERNAL(PTR) && VARTAG_EXTERNAL(PTR) == VARTAG_ONDISK)
-#define VARATT_IS_EXTERNAL_INDIRECT(PTR) \
-       (VARATT_IS_EXTERNAL(PTR) && VARTAG_EXTERNAL(PTR) == VARTAG_INDIRECT)
-#define VARATT_IS_EXTERNAL_EXPANDED_RO(PTR) \
-       (VARATT_IS_EXTERNAL(PTR) && VARTAG_EXTERNAL(PTR) == VARTAG_EXPANDED_RO)
-#define VARATT_IS_EXTERNAL_EXPANDED_RW(PTR) \
-       (VARATT_IS_EXTERNAL(PTR) && VARTAG_EXTERNAL(PTR) == VARTAG_EXPANDED_RW)
-#define VARATT_IS_EXTERNAL_EXPANDED(PTR) \
-       (VARATT_IS_EXTERNAL(PTR) && VARTAG_IS_EXPANDED(VARTAG_EXTERNAL(PTR)))
-#define VARATT_IS_EXTERNAL_NON_EXPANDED(PTR) \
-       (VARATT_IS_EXTERNAL(PTR) && !VARTAG_IS_EXPANDED(VARTAG_EXTERNAL(PTR)))
-#define VARATT_IS_SHORT(PTR)                           VARATT_IS_1B(PTR)
-#define VARATT_IS_EXTENDED(PTR)                                
(!VARATT_IS_4B_U(PTR))
-
-#define SET_VARSIZE(PTR, len)                          SET_VARSIZE_4B(PTR, len)
-#define SET_VARSIZE_SHORT(PTR, len)                    SET_VARSIZE_1B(PTR, len)
-#define SET_VARSIZE_COMPRESSED(PTR, len)       SET_VARSIZE_4B_C(PTR, len)
-
-#define SET_VARTAG_EXTERNAL(PTR, tag)          SET_VARTAG_1B_E(PTR, tag)
-
-#define VARSIZE_ANY(PTR) \
-       (VARATT_IS_1B_E(PTR) ? VARSIZE_EXTERNAL(PTR) : \
-        (VARATT_IS_1B(PTR) ? VARSIZE_1B(PTR) : \
-         VARSIZE_4B(PTR)))
-
-/* Size of a varlena data, excluding header */
-#define VARSIZE_ANY_EXHDR(PTR) \
-       (VARATT_IS_1B_E(PTR) ? VARSIZE_EXTERNAL(PTR)-VARHDRSZ_EXTERNAL : \
-        (VARATT_IS_1B(PTR) ? VARSIZE_1B(PTR)-VARHDRSZ_SHORT : \
-         VARSIZE_4B(PTR)-VARHDRSZ))
-
-/* caution: this will not work on an external or compressed-in-line Datum */
-/* caution: this will return a possibly unaligned pointer */
-#define VARDATA_ANY(PTR) \
-        (VARATT_IS_1B(PTR) ? VARDATA_1B(PTR) : VARDATA_4B(PTR))
-
-/* Decompressed size and compression method of a compressed-in-line Datum */
-#define VARDATA_COMPRESSED_GET_EXTSIZE(PTR) \
-       (((varattrib_4b *) (PTR))->va_compressed.va_tcinfo & 
VARLENA_EXTSIZE_MASK)
-#define VARDATA_COMPRESSED_GET_COMPRESS_METHOD(PTR) \
-       (((varattrib_4b *) (PTR))->va_compressed.va_tcinfo >> 
VARLENA_EXTSIZE_BITS)
-
-/* Same for external Datums; but note argument is a struct varatt_external */
-#define VARATT_EXTERNAL_GET_EXTSIZE(toast_pointer) \
-       ((toast_pointer).va_extinfo & VARLENA_EXTSIZE_MASK)
-#define VARATT_EXTERNAL_GET_COMPRESS_METHOD(toast_pointer) \
-       ((toast_pointer).va_extinfo >> VARLENA_EXTSIZE_BITS)
-
-#define VARATT_EXTERNAL_SET_SIZE_AND_COMPRESS_METHOD(toast_pointer, len, cm) \
-       do { \
-               Assert((cm) == TOAST_PGLZ_COMPRESSION_ID || \
-                          (cm) == TOAST_LZ4_COMPRESSION_ID); \
-               ((toast_pointer).va_extinfo = \
-                       (len) | ((uint32) (cm) << VARLENA_EXTSIZE_BITS)); \
-       } while (0)
-
-/*
- * Testing whether an externally-stored value is compressed now requires
- * comparing size stored in va_extinfo (the actual length of the external data)
- * to rawsize (the original uncompressed datum's size).  The latter includes
- * VARHDRSZ overhead, the former doesn't.  We never use compression unless it
- * actually saves space, so we expect either equality or less-than.
- */
-#define VARATT_EXTERNAL_IS_COMPRESSED(toast_pointer) \
-       (VARATT_EXTERNAL_GET_EXTSIZE(toast_pointer) < \
-        (toast_pointer).va_rawsize - VARHDRSZ)
-
-
-/* ----------------------------------------------------------------
- *                             Section 2:      Datum type + support macros
-=======
  *                             Section 1:      Datum type + support functions
->>>>>>> REL_16_9
  * ----------------------------------------------------------------
  */
 
@@ -423,7 +57,6 @@ typedef struct
  *
  * sizeof(Datum) == sizeof(void *) == 4 or 8
  *
-<<<<<<< HEAD
  *  Cloudberry CDB:
  *     Datum is always 8 bytes, regardless if it is 32bit or 64bit machine.
  *  so may be > sizeof(void *). To align with postgres, which defines Datum as
@@ -432,10 +65,7 @@ typedef struct
  *  uintptr_t is 64bits which doesn't violate the original 64bits definition.
  *  Although it is unclear why did GPDB had that restriction at the beginning.
  *
- * The macros below and the analogous macros for other types should be used to
-=======
  * The functions below and the analogous functions for other types should be 
used to
->>>>>>> REL_16_9
  * convert between a Datum and the appropriate C type.
  */
 
@@ -480,35 +110,6 @@ StaticAssertDecl(SIZEOF_DATUM == 8, "sizeof datum is not 
8");
  *
  * Note: any nonzero value will be considered true.
  */
-<<<<<<< HEAD
-static inline bool DatumGetBool(Datum d) { return (bool)(d != 0); }
-static inline Datum BoolGetDatum(bool b) { return (b ? 1 : 0); } 
-
-static inline char DatumGetChar(Datum d) { return (char) d; }
-static inline Datum CharGetDatum(char c) { return (Datum) c; } 
-
-static inline int8 DatumGetInt8(Datum d) { return (int8) d; } 
-static inline Datum Int8GetDatum(int8 i8) { return (Datum) i8; }
-
-static inline uint8 DatumGetUInt8(Datum d) { return (uint8) d; } 
-static inline Datum UInt8GetDatum(uint8 ui8) { return (Datum) ui8; } 
-
-static inline int16 DatumGetInt16(Datum d) { return (int16) d; } 
-static inline Datum Int16GetDatum(int16 i16) { return (Datum) i16; } 
-
-static inline uint16 DatumGetUInt16(Datum d) { return (uint16) d; } 
-static inline Datum UInt16GetDatum(uint16 ui16) { return (Datum) ui16; } 
-
-static inline int32 DatumGetInt32(Datum d) { return (int32) d; } 
-static inline Datum Int32GetDatum(int32 i32) { return (Datum) i32; } 
-
-static inline uint32 DatumGetUInt32(Datum d) { return (uint32) d; } 
-static inline Datum UInt32GetDatum(uint32 ui32) { return (Datum) ui32; } 
-
-static inline int64 DatumGetInt64(Datum d) { return (int64) d; } 
-static inline Datum Int64GetDatum(int64 i64) { return (Datum) i64; } 
-static inline Datum Int64GetDatumFast(int64 x) { return Int64GetDatum(x); } 
-=======
 static inline bool
 DatumGetBool(Datum X)
 {
@@ -830,7 +431,6 @@ Int64GetDatum(int64 X)
 #else
 extern Datum Int64GetDatum(int64 X);
 #endif
->>>>>>> REL_16_9
 
 
 /*
@@ -866,20 +466,8 @@ UInt64GetDatum(uint64 X)
 #endif
 }
 
-static inline Oid DatumGetObjectId(Datum d) { return (Oid) d; } 
-static inline Datum ObjectIdGetDatum(Oid oid) { return (Datum) oid; } 
-
-static inline TransactionId DatumGetTransactionId(Datum d) { return 
(TransactionId) d; } 
-static inline Datum TransactionIdGetDatum(TransactionId tid) { return (Datum) 
tid; } 
-
 static inline Datum DistributedTransactionIdGetDatum(DistributedTransactionId 
tid) { return (Datum) tid; } 
 
-static inline TransactionId DatumGetMultiXactId(Datum d) { return 
(TransactionId) d; } 
-static inline Datum MultiXactIdGetDatum(TransactionId tid) { return (Datum) 
tid; } 
-
-static inline CommandId DatumGetCommandId(Datum d) { return (CommandId) d; } 
-static inline Datum CommandIdGetDatum(CommandId cid) { return (Datum) cid; } 
-
 /*
  * DatumGetPointer
  *             Returns pointer value of a datum.
@@ -887,26 +475,6 @@ static inline Datum CommandIdGetDatum(CommandId cid) { 
return (Datum) cid; }
 #define DatumGetPointer(X) ((Pointer) (X))
 
 /*
-<<<<<<< HEAD
- * PointerGetDatum
- *             Returns datum representation for a pointer.
- */
-
-#define PointerGetDatum(X) ((Datum) (X))
-
-static inline char *DatumGetCString(Datum d) { return (char* ) 
DatumGetPointer(d); } 
-static inline Datum CStringGetDatum(const char *p) { return 
PointerGetDatum(p); }
-
-static inline Name DatumGetName(Datum d) { return (Name) DatumGetPointer(d); }
-static inline Datum NameGetDatum(const Name n) { return PointerGetDatum(n); }
-
-#ifndef WORDS_BIGENDIAN 
-static inline float4 DatumGetFloat4(Datum d) { Datum_U du; du.d = d; return 
du.f4[0]; } 
-static inline Datum Float4GetDatum(float4 f) { Datum_U du; du.d = 0; du.f4[0] 
= f; return du.d; } 
-#else
-static inline float4 DatumGetFloat4(Datum d) { Datum_U du; du.d = d; return 
du.f4[1]; } 
-static inline Datum Float4GetDatum(float4 f) { Datum_U du; du.d = 0; du.f4[1] 
= f; return du.d; } 
-=======
  * Float4GetDatum
  *             Returns datum representation for a 4-byte floating point number.
  */
@@ -943,21 +511,9 @@ DatumGetFloat8(Datum X)
        return myunion.retval;
 #else
        return *((float8 *) DatumGetPointer(X));
->>>>>>> REL_16_9
 #endif
 }
 
-<<<<<<< HEAD
-static inline float8 DatumGetFloat8(Datum d) { Datum_U du; du.d = d; return 
du.f8; } 
-static inline Datum Float8GetDatum(float8 f) { Datum_U du; du.f8 = f; return 
du.d; }
-static inline Datum Float8GetDatumFast(float8 f) { return Float8GetDatum(f); }
-
-static inline ItemPointer DatumGetItemPointer(Datum d) { return (ItemPointer) 
DatumGetPointer(d); }
-static inline Datum ItemPointerGetDatum(ItemPointer i) { return 
PointerGetDatum(i); }
-
-
-static inline bool IsAligned(void *p, int align)
-=======
 /*
  * Float8GetDatum
  *             Returns datum representation for an 8-byte floating point 
number.
@@ -968,13 +524,20 @@ static inline bool IsAligned(void *p, int align)
 #ifdef USE_FLOAT8_BYVAL
 static inline Datum
 Float8GetDatum(float8 X)
->>>>>>> REL_16_9
 {
-        int64 i = (int64) PointerGetDatum(p);
-        return ((i & (align-1)) == 0);
+       union
+       {
+               float8          value;
+               int64           retval;
+       }                       myunion;
+
+       myunion.value = X;
+       return Int64GetDatum(myunion.retval);
 }
+#else
+extern Datum Float8GetDatum(float8 X);
+#endif
 
-<<<<<<< HEAD
 /* ----------------------------------------------------------------
  *                             Section 3:      exception handling backend 
support
  * ----------------------------------------------------------------
@@ -983,16 +546,6 @@ Float8GetDatum(float8 X)
 #define COMPILE_ASSERT(e) ((void)sizeof(char[1-2*!(e)]))
 #define ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x)))
 
-/*
- * Backend only infrastructure for the assertion-related macros in c.h.
- *
- * ExceptionalCondition must be present even when assertions are not enabled.
- */
-extern void ExceptionalCondition(const char *conditionName,
-                                        const char *errorType,
-                          const char *fileName, int lineNumber) 
pg_attribute_noreturn();
-=======
-
 /*
  * Int64GetDatumFast
  * Float8GetDatumFast
@@ -1036,6 +589,5 @@ extern void ExceptionalCondition(const char *conditionName,
 #else
 #define NON_EXEC_STATIC static
 #endif
->>>>>>> REL_16_9
 
 #endif                                                 /* POSTGRES_H */
diff --git a/src/include/varatt.h b/src/include/varatt.h
index e34870526ba..737bfc596b4 100644
--- a/src/include/varatt.h
+++ b/src/include/varatt.h
@@ -86,7 +86,8 @@ typedef enum vartag_external
        VARTAG_INDIRECT = 1,
        VARTAG_EXPANDED_RO = 2,
        VARTAG_EXPANDED_RW = 3,
-       VARTAG_ONDISK = 18
+       VARTAG_ONDISK = 20,
+       VARTAG_CUSTOM = 21 /* external toast custom defined tag */
 } vartag_external;
 
 /* this test relies on the specific tag values above */
@@ -135,6 +136,7 @@ typedef struct
 {
        uint8           va_header;              /* Always 0x80 or 0x01 */
        uint8           va_tag;                 /* Type of datum */
+       uint8           va_padding[2];  /*** GPDB only:  Alignment padding ***/
        char            va_data[FLEXIBLE_ARRAY_MEMBER]; /* Type-specific data */
 } varattrib_1b_e;
 
@@ -205,6 +207,7 @@ typedef struct
 #define SET_VARTAG_1B_E(PTR,tag) \
        (((varattrib_1b_e *) (PTR))->va_header = 0x80, \
         ((varattrib_1b_e *) (PTR))->va_tag = (tag))
+#define VARSIZE_TO_SHORT(PTR)   ((char)(VARSIZE(PTR)-VARHDRSZ+VARHDRSZ_SHORT) 
| 0x80)
 
 #else                                                  /* !WORDS_BIGENDIAN */
 
@@ -238,6 +241,7 @@ typedef struct
 #define SET_VARTAG_1B_E(PTR,tag) \
        (((varattrib_1b_e *) (PTR))->va_header = 0x01, \
         ((varattrib_1b_e *) (PTR))->va_tag = (tag))
+#define VARSIZE_TO_SHORT(PTR)  ((char)((VARSIZE(PTR)-VARHDRSZ+VARHDRSZ_SHORT) 
<< 1) | 0x01)
 
 #endif                                                 /* WORDS_BIGENDIAN */
 
@@ -280,6 +284,8 @@ typedef struct
 
 #define VARSIZE_SHORT(PTR)                                     VARSIZE_1B(PTR)
 #define VARDATA_SHORT(PTR)                                     VARDATA_1B(PTR)
+/* Use short var-attrib */
+#define VARSIZE_TO_SHORT_D(D)                          
VARSIZE_TO_SHORT(DatumGetPointer(D))
 
 #define VARTAG_EXTERNAL(PTR)                           VARTAG_1B_E(PTR)
 #define VARSIZE_EXTERNAL(PTR)                          (VARHDRSZ_EXTERNAL + 
VARTAG_SIZE(VARTAG_EXTERNAL(PTR)))


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


Reply via email to