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 ff45cf10fed Fix some errors on linking
ff45cf10fed is described below
commit ff45cf10fedd15d3ba3741fea8b6d63f462b87ff
Author: Jinbao Chen <[email protected]>
AuthorDate: Wed Oct 8 11:15:14 2025 +0800
Fix some errors on linking
---
contrib/pg_surgery/heap_surgery.c | 2 +-
gpcontrib/orafce/assert.c | 2 +-
src/backend/access/transam/xlog.c | 70 +-----
src/backend/catalog/aclchk.c | 28 ---
src/backend/cdb/cdbsreh.c | 5 +-
src/backend/cdb/dispatcher/cdbgang.c | 4 +-
src/backend/commands/analyzefuncs.c | 4 +-
src/backend/commands/copyfrom.c | 386 ------------------------------
src/backend/commands/copyfromparse.c | 230 ++++++++++++++----
src/backend/commands/createas.c | 2 +-
src/backend/commands/dirtablecmds.c | 4 +-
src/backend/commands/tablecmds.c | 2 +-
src/backend/commands/vacuum.c | 4 +-
src/backend/optimizer/path/costsize.c | 2 +-
src/backend/optimizer/path/joinrels.c | 12 +-
src/backend/optimizer/plan/planner.c | 4 +-
src/backend/optimizer/prep/prepjointree.c | 2 +-
src/backend/optimizer/util/clauses.c | 16 +-
src/backend/parser/parse_agg.c | 10 +-
src/backend/postmaster/autostats.c | 5 +-
src/include/commands/copy.h | 2 +
src/include/commands/copyfrom_internal.h | 2 +
src/include/miscadmin.h | 1 -
src/include/optimizer/optimizer.h | 2 +-
src/include/utils/acl.h | 25 --
25 files changed, 234 insertions(+), 592 deletions(-)
diff --git a/contrib/pg_surgery/heap_surgery.c
b/contrib/pg_surgery/heap_surgery.c
index 5089b427613..6a77e45b558 100644
--- a/contrib/pg_surgery/heap_surgery.c
+++ b/contrib/pg_surgery/heap_surgery.c
@@ -407,7 +407,7 @@ sanity_check_relation(Relation rel)
errmsg("only heap AM is supported")));
/* Must be owner of the table or superuser. */
- if (!pg_class_ownercheck(RelationGetRelid(rel), GetUserId()))
+ if (!object_ownercheck(RelationRelationId, RelationGetRelid(rel),
GetUserId()))
aclcheck_error(ACLCHECK_NOT_OWNER,
get_relkind_objtype(rel->rd_rel->relkind),
RelationGetRelationName(rel));
diff --git a/gpcontrib/orafce/assert.c b/gpcontrib/orafce/assert.c
index 1c1a58ea357..d1574a4933d 100644
--- a/gpcontrib/orafce/assert.c
+++ b/gpcontrib/orafce/assert.c
@@ -302,7 +302,7 @@ dbms_assert_schema_name(PG_FUNCTION_ARGS)
#else
- aclresult = pg_namespace_aclcheck(namespaceId, GetUserId(), ACL_USAGE);
+ aclresult = object_aclcheck(NamespaceRelationId, namespaceId,
GetUserId(), ACL_USAGE);
#endif
diff --git a/src/backend/access/transam/xlog.c
b/src/backend/access/transam/xlog.c
index b35b9ee8eef..9cc43869e82 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -250,21 +250,6 @@ CheckpointStatsData CheckpointStats;
*/
TimeLineID ThisTimeLineID = 0;
-/*
- * Are we doing recovery from XLOG?
- *
- * This is only ever true in the startup process; it should be read as meaning
- * "this process is replaying WAL records", rather than "the system is in
- * recovery mode". It should be examined primarily by functions that need
- * to act differently when called from a WAL redo function (e.g., to skip WAL
- * logging). To check whether the system is in recovery regardless of which
- * process you're running in, use RecoveryInProgress() but only after shared
- * memory startup and lock initialization.
- */
-bool InRecovery = false;
-
-/* Are we in Hot Standby mode? Only valid in startup process, see xlog.h */
-HotStandbyState standbyState = STANDBY_DISABLED;
static XLogRecPtr missingContrecPtr;
@@ -306,34 +291,15 @@ static int LocalXLogInsertAllowed = -1;
* will switch to using offline XLOG archives as soon as we reach the end of
* WAL in pg_wal.
*/
-bool ArchiveRecoveryRequested = false;
-bool InArchiveRecovery = false;
static bool standby_signal_file_found = false;
static bool recovery_signal_file_found = false;
-/* options formerly taken from recovery.conf for archive recovery */
-char *recoveryRestoreCommand = NULL;
-char *recoveryEndCommand = NULL;
-char *archiveCleanupCommand = NULL;
-RecoveryTargetType recoveryTarget = RECOVERY_TARGET_UNSET;
-bool recoveryTargetInclusive = true;
-int recoveryTargetAction = RECOVERY_TARGET_ACTION_PAUSE;
-TransactionId recoveryTargetXid;
-char *recovery_target_time_string;
-const char *recoveryTargetName;
-XLogRecPtr recoveryTargetLSN;
-int recovery_min_apply_delay = 0;
/* options formerly taken from recovery.conf for XLOG streaming */
bool StandbyModeRequested = false;
-char *PrimaryConnInfo = NULL;
-char *PrimarySlotName = NULL;
char *PromoteTriggerFile = NULL;
-bool wal_receiver_create_temp_slot = false;
-/* are we currently in standby mode? */
-bool StandbyMode = false;
Startup_hook_type Startup_hook = NULL;
@@ -342,36 +308,6 @@ ConsistencyCheck_hook_type xlog_check_consistency_hook =
NULL;
XLOGDropDatabase_hook_type XLOGDropDatabase_hook = NULL;
-/*
- * During normal operation, the only timeline we care about is ThisTimeLineID.
- * During recovery, however, things are more complicated. To simplify life
- * for rmgr code, we keep ThisTimeLineID set to the "current" timeline as we
- * scan through the WAL history (that is, it is the line that was active when
- * the currently-scanned WAL record was generated). We also need these
- * timeline values:
- *
- * recoveryTargetTimeLineGoal: what the user requested, if any
- *
- * recoveryTargetTLIRequested: numeric value of requested timeline, if constant
- *
- * recoveryTargetTLI: the currently understood target timeline; changes
- *
- * expectedTLEs: a list of TimeLineHistoryEntries for recoveryTargetTLI and
the timelines of
- * its known parents, newest first (so recoveryTargetTLI is always the
- * first list member). Only these TLIs are expected to be seen in the WAL
- * segments we read, and indeed only these TLIs will be considered as
- * candidate WAL files to open at all.
- *
- * curFileTLI: the TLI appearing in the name of the current input WAL file.
- * (This is not necessarily the same as ThisTimeLineID, because we could
- * be scanning data that was copied from an ancestor timeline when the current
- * file was created.) During a sequential scan we do not allow this value
- * to decrease.
- */
-RecoveryTargetTimeLineGoal recoveryTargetTimeLineGoal =
RECOVERY_TARGET_TIMELINE_LATEST;
-TimeLineID recoveryTargetTLIRequested = 0;
-TimeLineID recoveryTargetTLI = 0;
-
/*
* ProcLastRecPtr points to the start of the last XLOG record inserted by the
* current backend. It is updated for all inserts. XactLastRecEnd points to
@@ -7231,8 +7167,7 @@ CreateCheckPoint(int flags)
*/
AbsorbSyncRequests();
pg_usleep(10000L); /* wait for 10 msec */
- } while (HaveVirtualXIDsDelayingChkpt(vxids, nvxids,
-
DELAY_CHKPT_START));
+ } while (HaveVirtualXIDsDelayingChkpt(vxids, nvxids));
}
pfree(vxids);
@@ -7278,8 +7213,7 @@ CreateCheckPoint(int flags)
{
AbsorbSyncRequests();
pg_usleep(10000L); /* wait for 10 msec */
- } while (HaveVirtualXIDsDelayingChkpt(vxids, nvxids,
-
DELAY_CHKPT_COMPLETE));
+ } while (HaveVirtualXIDsDelayingChkpt(vxids, nvxids));
}
pfree(vxids);
diff --git a/src/backend/catalog/aclchk.c b/src/backend/catalog/aclchk.c
index a573ebfd95f..28e37f72ba1 100644
--- a/src/backend/catalog/aclchk.c
+++ b/src/backend/catalog/aclchk.c
@@ -4541,34 +4541,6 @@ gp_storage_server_ownercheck(Oid srv_oid, Oid roleid)
return has_privs_of_role(roleid, ownerId);
}
-/*
- * Ownership check for an event trigger (specified by OID).
- */
-bool
-pg_event_trigger_ownercheck(Oid et_oid, Oid roleid)
-{
- HeapTuple tuple;
- Oid ownerId;
-
- /* Superusers bypass all permission checking. */
- if (superuser_arg(roleid))
- return true;
-
- tuple = SearchSysCache1(EVENTTRIGGEROID, ObjectIdGetDatum(et_oid));
- if (!HeapTupleIsValid(tuple))
- ereport(ERROR,
- (errcode(ERRCODE_UNDEFINED_OBJECT),
- errmsg("event trigger with OID
%u does not exist",
- et_oid)));
-
- ownerId = ((Form_pg_event_trigger) GETSTRUCT(tuple))->evtowner;
-
- ReleaseSysCache(tuple);
-
- return has_privs_of_role(roleid, ownerId);
-}
-
-
/*
* Ownership check for an external protocol (specified by OID).
*/
diff --git a/src/backend/cdb/cdbsreh.c b/src/backend/cdb/cdbsreh.c
index efcb64b1d5e..22eaeaba65e 100644
--- a/src/backend/cdb/cdbsreh.c
+++ b/src/backend/cdb/cdbsreh.c
@@ -25,6 +25,7 @@
#include "catalog/gp_distribution_policy.h"
#include "catalog/namespace.h"
#include "catalog/pg_attribute.h"
+#include "catalog/pg_database.h"
#include "catalog/pg_namespace.h"
#include "catalog/pg_type.h"
#include "cdb/cdbdisp_query.h"
@@ -781,7 +782,7 @@ RetrievePersistentErrorLogFromRangeVar(RangeVar *relrv,
AclMode mode, char *fnam
if (findfile)
{
/* Requires priv on namespace to operate error log. */
- aclresult = pg_namespace_aclcheck(namespaceId, GetUserId(),
mode);
+ aclresult = object_aclcheck(NamespaceRelationId, namespaceId,
GetUserId(), mode);
if (aclresult != ACLCHECK_OK)
aclcheck_error(aclresult, OBJECT_SCHEMA, schemaname);
return true;
@@ -1029,7 +1030,7 @@ TruncateErrorLog(text *relname, bool persistent)
/*
* Database owner can delete error log files.
*/
- if (!pg_database_ownercheck(MyDatabaseId, GetUserId()))
+ if (!object_ownercheck(DatabaseRelationId, MyDatabaseId,
GetUserId()))
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_DATABASE,
get_database_name(MyDatabaseId));
diff --git a/src/backend/cdb/dispatcher/cdbgang.c
b/src/backend/cdb/dispatcher/cdbgang.c
index f226073e1a3..c29d9f059d4 100644
--- a/src/backend/cdb/dispatcher/cdbgang.c
+++ b/src/backend/cdb/dispatcher/cdbgang.c
@@ -441,8 +441,8 @@ addOneOption(StringInfo option, StringInfo diff, struct
config_generic *guc)
void
makeOptions(char **options, char **diff_options)
{
- struct config_generic **gucs = get_guc_variables();
- int ngucs = get_num_guc_variables();
+ int ngucs;
+ struct config_generic **gucs = get_guc_variables(&ngucs);
CdbComponentDatabaseInfo *qdinfo = NULL;
StringInfoData optionsStr;
StringInfoData diffStr;
diff --git a/src/backend/commands/analyzefuncs.c
b/src/backend/commands/analyzefuncs.c
index 8c9fd56199d..578a1686d7c 100644
--- a/src/backend/commands/analyzefuncs.c
+++ b/src/backend/commands/analyzefuncs.c
@@ -123,7 +123,7 @@ gp_acquire_sample_rows(PG_FUNCTION_ARGS)
ctx->targrows = targrows;
ctx->inherited = inherited;
- if (!pg_class_ownercheck(relOid, GetUserId()))
+ if (!object_ownercheck(RelationRelationId, relOid, GetUserId()))
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_TABLE,
get_rel_name(relOid));
@@ -410,7 +410,7 @@ gp_acquire_correlations(PG_FUNCTION_ARGS)
/* Construct the context to keep across calls. */
ctx = (gp_acquire_correlation_context *)
palloc0(sizeof(gp_acquire_correlation_context));
- if (!pg_class_ownercheck(relOid, GetUserId()))
+ if (!object_ownercheck(RelationRelationId, relOid, GetUserId()))
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_TABLE,
get_rel_name(relOid));
diff --git a/src/backend/commands/copyfrom.c b/src/backend/commands/copyfrom.c
index 851e891bd54..f616f653c94 100644
--- a/src/backend/commands/copyfrom.c
+++ b/src/backend/commands/copyfrom.c
@@ -202,10 +202,6 @@ static void SendCopyFromForwardedError(CopyFromState
cstate, CdbCopy *cdbCopy, c
static bool NextCopyFromDispatch(CopyFromState cstate, ExprContext *econtext,
Datum *values,
bool *nulls);
static bool NextCopyFromExecute(CopyFromState cstate, ExprContext *econtext,
Datum *values, bool *nulls, bool is_directory_table);
-static bool NextCopyFromRawFieldsX(CopyFromState cstate, char ***fields, int
*nfields,
- int
stop_processing_at_field);
-static bool NextCopyFromX(CopyFromState cstate, ExprContext *econtext,
- Datum *values, bool *nulls);
static void HandleQDErrorFrame(CopyFromState cstate, char *p);
static void CopyInitDataParser(CopyFromState cstate);
@@ -3224,101 +3220,6 @@ BeginCopyFrom(ParseState *pstate,
return cstate;
}
-/*
- * Read raw fields in the next line for COPY FROM in text or csv mode.
- * Return false if no more lines.
- *
- * An internal temporary buffer is returned via 'fields'. It is valid until
- * the next call of the function. Since the function returns all raw fields
- * in the input file, 'nfields' could be different from the number of columns
- * in the relation.
- *
- * NOTE: force_not_null option are not applied to the returned fields.
- */
-bool
-NextCopyFromRawFields(CopyFromState cstate, char ***fields, int *nfields)
-{
- return NextCopyFromRawFieldsX(cstate, fields, nfields, -1);
-}
-
-static bool
-NextCopyFromRawFieldsX(CopyFromState cstate, char ***fields, int *nfields,
- int stop_processing_at_field)
-{
- int fldct;
- bool done;
-
- /* only available for text or csv input */
- Assert(!cstate->opts.binary);
-
- /* on input just throw the header line away */
- if (cstate->cur_lineno == 0 && cstate->opts.header_line)
- {
- cstate->cur_lineno++;
- if (CopyReadLine(cstate))
- return false; /* done */
- }
-
- cstate->cur_lineno++;
-
- /* Actually read the line into memory here */
- done = CopyReadLine(cstate);
-
- /*
- * EOF at start of line means we're done. If we see EOF after some
- * characters, we act as though it was newline followed by EOF, ie,
- * process the line and then exit loop on next iteration.
- */
- if (done && cstate->line_buf.len == 0)
- return false;
-
- /* Parse the line into de-escaped field values */
- if (cstate->opts.csv_mode)
- fldct = CopyReadAttributesCSV(cstate, stop_processing_at_field);
- else
- fldct = CopyReadAttributesText(cstate,
stop_processing_at_field);
-
- *fields = cstate->raw_fields;
- *nfields = fldct;
- return true;
-}
-
-bool
-NextCopyFrom(CopyFromState cstate, ExprContext *econtext,
- Datum *values, bool *nulls)
-{
- if (!cstate->cdbsreh)
- return NextCopyFromX(cstate, econtext, values, nulls);
- else
- {
- MemoryContext oldcontext = CurrentMemoryContext;
-
- for (;;)
- {
- bool got_error = false;
- bool result = false;
-
- PG_TRY();
- {
- result = NextCopyFromX(cstate, econtext,
values, nulls);
- }
- PG_CATCH();
- {
- HandleCopyError(cstate); /* cdbsreh->processed
is updated inside here */
- got_error = true;
- MemoryContextSwitchTo(oldcontext);
- }
- PG_END_TRY();
-
- if (result)
- cstate->cdbsreh->processed++;
-
- if (!got_error)
- return result;
- }
- }
-}
-
/*
* A data error happened. This code block will always be inside a PG_CATCH()
* block right when a higher stack level produced an error. We handle the error
@@ -3414,293 +3315,6 @@ HandleCopyError(CopyFromState cstate)
}
}
-
-/*
- * Read next tuple from file for COPY FROM. Return false if no more tuples.
- *
- * 'econtext' is used to evaluate default expression for each columns not
- * read from the file. It can be NULL when no default values are used, i.e.
- * when all columns are read from the file.
- *
- * 'values' and 'nulls' arrays must be the same length as columns of the
- * relation passed to BeginCopyFrom. This function fills the arrays.
- */
-bool
-NextCopyFromX(CopyFromState cstate, ExprContext *econtext,
- Datum *values, bool *nulls)
-{
- TupleDesc tupDesc;
- AttrNumber num_phys_attrs,
- attr_count,
- num_defaults = cstate->num_defaults;
- FmgrInfo *in_functions = cstate->in_functions;
- Oid *typioparams = cstate->typioparams;
- int i;
- int *defmap = cstate->defmap;
- ExprState **defexprs = cstate->defexprs;
- List *attnumlist;
- int stop_processing_at_field;
-
- /*
- * Figure out what fields we're going to process in this process.
- *
- * In the QD, set 'stop_processing_at_field' so that we only those
- * fields that are needed in the QD.
- */
- switch (cstate->dispatch_mode)
- {
- case COPY_DIRECT:
- stop_processing_at_field = -1;
- attnumlist = cstate->attnumlist;
- break;
-
- case COPY_DISPATCH:
- stop_processing_at_field =
cstate->first_qe_processed_field;
- attnumlist = cstate->qd_attnumlist;
- break;
-
- case COPY_EXECUTOR:
- stop_processing_at_field = -1;
- attnumlist = cstate->qe_attnumlist;
- break;
-
- default:
- elog(ERROR, "unexpected COPY dispatch mode %d",
cstate->dispatch_mode);
- }
-
- tupDesc = RelationGetDescr(cstate->rel);
- num_phys_attrs = tupDesc->natts;
- attr_count = list_length(attnumlist);
-
- /* Initialize all values for row to NULL */
- MemSet(values, 0, num_phys_attrs * sizeof(Datum));
- MemSet(nulls, true, num_phys_attrs * sizeof(bool));
-
- if (!cstate->opts.binary)
- {
- char **field_strings;
- ListCell *cur;
- int fldct;
- int fieldno;
- char *string;
-
- /* read raw fields in the next line */
- if (cstate->dispatch_mode != COPY_EXECUTOR)
- {
- if (!NextCopyFromRawFieldsX(cstate, &field_strings,
&fldct,
-
stop_processing_at_field))
- return false;
- }
- else
- {
- /*
- * We have received the raw line from the QD, and we
just
- * need to split it into raw fields.
- */
- if (cstate->stopped_processing_at_delim &&
- cstate->line_buf.cursor <= cstate->line_buf.len)
- {
- if (cstate->opts.csv_mode)
- fldct = CopyReadAttributesCSV(cstate,
-1);
- else
- fldct = CopyReadAttributesText(cstate,
-1);
- }
- else
- fldct = 0;
- field_strings = cstate->raw_fields;
- }
- /*
- * Check for overflowing fields.
- * GPDB: Change below condition compared to upstream to
- * greater than or equal to 0 as in QE,
- * attr_count may be equal to 0,
- * when all fields are processed in the QD.
- */
- if (fldct > attr_count)
- ereport(ERROR,
- (errcode(ERRCODE_BAD_COPY_FILE_FORMAT),
- errmsg("extra data after last expected
column")));
-
- /*
- * A completely empty line is not allowed with FILL MISSING
FIELDS. Without
- * FILL MISSING FIELDS, it's almost surely an error, but not
always:
- * a table with a single text column, for example, needs to
accept empty
- * lines.
- */
- if (cstate->line_buf.len == 0 &&
- cstate->opts.fill_missing &&
- list_length(cstate->attnumlist) > 1)
- {
- ereport(ERROR,
- (errcode(ERRCODE_BAD_COPY_FILE_FORMAT),
- errmsg("missing data for column
\"%s\", found empty data line",
-
NameStr(TupleDescAttr(tupDesc, 1)->attname))));
- }
-
- fieldno = 0;
-
- /* Loop to read the user attributes on the line. */
- foreach(cur, attnumlist)
- {
- int attnum = lfirst_int(cur);
- int m = attnum - 1;
- Form_pg_attribute att = TupleDescAttr(tupDesc, m);
-
- if (fieldno >= fldct)
- {
- /*
- * Some attributes are missing. In FILL MISSING
FIELDS mode,
- * treat them as NULLs.
- */
- if (!cstate->opts.fill_missing)
- ereport(ERROR,
-
(errcode(ERRCODE_BAD_COPY_FILE_FORMAT),
- errmsg("missing data for
column \"%s\"",
-
NameStr(att->attname))));
- fieldno++;
- string = NULL;
- }
- else
- string = field_strings[fieldno++];
-
- if (cstate->convert_select_flags &&
- !cstate->convert_select_flags[m])
- {
- /* ignore input field, leaving column as NULL */
- continue;
- }
-
- if (cstate->opts.csv_mode)
- {
- if (string == NULL &&
- cstate->opts.force_notnull_flags[m])
- {
- /*
- * FORCE_NOT_NULL option is set and
column is NULL -
- * convert it to the NULL string.
- */
- string = cstate->opts.null_print;
- }
- else if (string != NULL &&
cstate->opts.force_null_flags[m]
- && strcmp(string,
cstate->opts.null_print) == 0)
- {
- /*
- * FORCE_NULL option is set and column
matches the NULL
- * string. It must have been quoted, or
otherwise the
- * string would already have been set
to NULL. Convert it
- * to NULL as specified.
- */
- string = NULL;
- }
- }
-
- cstate->cur_attname = NameStr(att->attname);
- cstate->cur_attval = string;
- values[m] = InputFunctionCall(&in_functions[m],
-
string,
-
typioparams[m],
-
att->atttypmod);
- if (string != NULL)
- nulls[m] = false;
- cstate->cur_attname = NULL;
- cstate->cur_attval = NULL;
- }
-
- Assert(fieldno == attr_count);
- }
- else if (attr_count)
- {
- /* binary */
- int16 fld_count;
- ListCell *cur;
-
- cstate->cur_lineno++;
-
- if (!CopyGetInt16(cstate, &fld_count))
- {
- /* EOF detected (end of file, or protocol-level EOF) */
- return false;
- }
-
- if (fld_count == -1)
- {
- /*
- * Received EOF marker. In a V3-protocol copy, wait
for the
- * protocol-level EOF, and complain if it doesn't come
- * immediately. This ensures that we correctly handle
CopyFail,
- * if client chooses to send that now.
- *
- * Note that we MUST NOT try to read more data in an
old-protocol
- * copy, since there is no protocol-level EOF marker
then. We
- * could go either way for copy from file, but choose
to throw
- * error if there's data after the EOF marker, for
consistency
- * with the new-protocol case.
- */
- char dummy;
-
- if (cstate->copy_src != COPY_FRONTEND &&
- CopyGetData(cstate, &dummy, 1, 1) > 0)
- ereport(ERROR,
-
(errcode(ERRCODE_BAD_COPY_FILE_FORMAT),
- errmsg("received copy data
after EOF marker")));
- return false;
- }
-
- if (fld_count != attr_count)
- ereport(ERROR,
- (errcode(ERRCODE_BAD_COPY_FILE_FORMAT),
- errmsg("row field count is %d,
expected %d",
- (int) fld_count,
attr_count)));
-
- i = 0;
- foreach(cur, attnumlist)
- {
- int attnum = lfirst_int(cur);
- int m = attnum - 1;
- Form_pg_attribute att = TupleDescAttr(tupDesc, m);
-
- cstate->cur_attname = NameStr(att->attname);
- i++;
- values[m] = CopyReadBinaryAttribute(cstate,
-
&in_functions[m],
-
typioparams[m],
-
att->atttypmod,
-
&nulls[m]);
- cstate->cur_attname = NULL;
- }
- }
-
- /*
- * Now compute and insert any defaults available for the columns not
- * provided by the input data. Anything not processed here or above
will
- * remain NULL.
- *
- * GPDB: The defaults are always computed in the QD, and are included
- * in the QD->QE stream as pre-computed Datums. Funny indentation, to
- * keep the indentation of the code inside the same as in upstream.
- * (We could improve this, and compute immutable defaults that don't
- * affect which segment the row belongs to, in the QE.)
- */
- if (cstate->dispatch_mode != COPY_EXECUTOR)
- {
- for (i = 0; i < num_defaults; i++)
- {
- /*
- * The caller must supply econtext and have switched into the
- * per-tuple memory context in it.
- */
- Assert(econtext != NULL);
- Assert(CurrentMemoryContext == econtext->ecxt_per_tuple_memory);
-
- values[defmap[i]] = ExecEvalExpr(defexprs[i], econtext,
-
&nulls[defmap[i]]);
- }
- }
-
- return true;
-}
-
-
/*
* Like NextCopyFrom(), but used in the QD, when we want to parse the
* input line only partially. We only want to parse enough fields needed
diff --git a/src/backend/commands/copyfromparse.c
b/src/backend/commands/copyfromparse.c
index 0383fde7fa8..75693da9a92 100644
--- a/src/backend/commands/copyfromparse.c
+++ b/src/backend/commands/copyfromparse.c
@@ -769,6 +769,14 @@ CopyReadBinaryData(CopyFromState cstate, char *dest, int
nbytes)
*/
bool
NextCopyFromRawFields(CopyFromState cstate, char ***fields, int *nfields)
+{
+ return NextCopyFromRawFieldsX(cstate, fields, nfields, -1);
+}
+
+
+bool
+NextCopyFromRawFieldsX(CopyFromState cstate, char ***fields, int *nfields,
+ int stop_processing_at_field)
{
int fldct;
bool done;
@@ -792,9 +800,9 @@ NextCopyFromRawFields(CopyFromState cstate, char ***fields,
int *nfields)
int fldnum;
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);
if (fldct != list_length(cstate->attnumlist))
ereport(ERROR,
@@ -856,34 +864,99 @@ NextCopyFromRawFields(CopyFromState cstate, char
***fields, int *nfields)
return true;
}
+
+bool
+NextCopyFrom(CopyFromState cstate, ExprContext *econtext,
+ Datum *values, bool *nulls)
+{
+ if (!cstate->cdbsreh)
+ return NextCopyFromX(cstate, econtext, values, nulls);
+ else
+ {
+ MemoryContext oldcontext = CurrentMemoryContext;
+
+ for (;;)
+ {
+ bool got_error = false;
+ bool result = false;
+
+ PG_TRY();
+ {
+ result = NextCopyFromX(cstate,
econtext, values, nulls);
+ }
+ PG_CATCH();
+ {
+ HandleCopyError(cstate); /*
cdbsreh->processed is updated inside here */
+ got_error = true;
+
MemoryContextSwitchTo(oldcontext);
+ }
+ PG_END_TRY();
+
+ if (result)
+ cstate->cdbsreh->processed++;
+
+ if (!got_error)
+ return result;
+ }
+ }
+}
+
/*
* Read next tuple from file for COPY FROM. Return false if no more tuples.
*
- * 'econtext' is used to evaluate default expression for each column that is
- * either not read from the file or is using the DEFAULT option of COPY FROM.
- * It can be NULL when no default values are used, i.e. when all columns are
- * read from the file, and DEFAULT option is unset.
+ * 'econtext' is used to evaluate default expression for each columns not
+ * read from the file. It can be NULL when no default values are used, i.e.
+ * when all columns are read from the file.
*
* 'values' and 'nulls' arrays must be the same length as columns of the
* relation passed to BeginCopyFrom. This function fills the arrays.
*/
bool
-NextCopyFrom(CopyFromState cstate, ExprContext *econtext,
- Datum *values, bool *nulls)
+NextCopyFromX(CopyFromState cstate, ExprContext *econtext,
+ Datum *values, bool *nulls)
{
TupleDesc tupDesc;
AttrNumber num_phys_attrs,
- attr_count,
- num_defaults = cstate->num_defaults;
+ attr_count,
+ num_defaults = cstate->num_defaults;
FmgrInfo *in_functions = cstate->in_functions;
Oid *typioparams = cstate->typioparams;
int i;
int *defmap = cstate->defmap;
ExprState **defexprs = cstate->defexprs;
+ List *attnumlist;
+ int stop_processing_at_field;
+
+ /*
+ * Figure out what fields we're going to process in this process.
+ *
+ * In the QD, set 'stop_processing_at_field' so that we only those
+ * fields that are needed in the QD.
+ */
+ switch (cstate->dispatch_mode)
+ {
+ case COPY_DIRECT:
+ stop_processing_at_field = -1;
+ attnumlist = cstate->attnumlist;
+ break;
+
+ case COPY_DISPATCH:
+ stop_processing_at_field =
cstate->first_qe_processed_field;
+ attnumlist = cstate->qd_attnumlist;
+ break;
+
+ case COPY_EXECUTOR:
+ stop_processing_at_field = -1;
+ attnumlist = cstate->qe_attnumlist;
+ break;
+
+ default:
+ elog(ERROR, "unexpected COPY dispatch mode %d",
cstate->dispatch_mode);
+ }
tupDesc = RelationGetDescr(cstate->rel);
num_phys_attrs = tupDesc->natts;
- attr_count = list_length(cstate->attnumlist);
+ attr_count = list_length(attnumlist);
/* Initialize all values for row to NULL */
MemSet(values, 0, num_phys_attrs * sizeof(Datum));
@@ -899,30 +972,83 @@ NextCopyFrom(CopyFromState cstate, ExprContext *econtext,
char *string;
/* read raw fields in the next line */
- if (!NextCopyFromRawFields(cstate, &field_strings, &fldct))
- return false;
+ if (cstate->dispatch_mode != COPY_EXECUTOR)
+ {
+ if (!NextCopyFromRawFieldsX(cstate, &field_strings,
&fldct,
+
stop_processing_at_field))
+ return false;
+ }
+ else
+ {
+ /*
+ * We have received the raw line from the QD, and we
just
+ * need to split it into raw fields.
+ */
+ if (cstate->stopped_processing_at_delim &&
+ cstate->line_buf.cursor <= cstate->line_buf.len)
+ {
+ if (cstate->opts.csv_mode)
+ fldct = CopyReadAttributesCSV(cstate,
-1);
+ else
+ fldct = CopyReadAttributesText(cstate,
-1);
+ }
+ else
+ fldct = 0;
+ field_strings = cstate->raw_fields;
+ }
+ /*
+ * Check for overflowing fields.
+ * GPDB: Change below condition compared to upstream to
+ * greater than or equal to 0 as in QE,
+ * attr_count may be equal to 0,
+ * when all fields are processed in the QD.
+ */
+ if (fldct > attr_count)
+ ereport(ERROR,
+ (errcode(ERRCODE_BAD_COPY_FILE_FORMAT),
+ errmsg("extra data
after last expected column")));
- /* check for overflowing fields */
- if (attr_count > 0 && fldct > attr_count)
+ /*
+ * A completely empty line is not allowed with FILL MISSING
FIELDS. Without
+ * FILL MISSING FIELDS, it's almost surely an error, but not
always:
+ * a table with a single text column, for example, needs to
accept empty
+ * lines.
+ */
+ if (cstate->line_buf.len == 0 &&
+ cstate->opts.fill_missing &&
+ list_length(cstate->attnumlist) > 1)
+ {
ereport(ERROR,
(errcode(ERRCODE_BAD_COPY_FILE_FORMAT),
- errmsg("extra data after last expected
column")));
+ errmsg("missing data
for column \"%s\", found empty data line",
+
NameStr(TupleDescAttr(tupDesc, 1)->attname))));
+ }
fieldno = 0;
/* Loop to read the user attributes on the line. */
- foreach(cur, cstate->attnumlist)
+ foreach(cur, attnumlist)
{
int attnum = lfirst_int(cur);
int m = attnum - 1;
Form_pg_attribute att = TupleDescAttr(tupDesc, m);
if (fieldno >= fldct)
- ereport(ERROR,
-
(errcode(ERRCODE_BAD_COPY_FILE_FORMAT),
- errmsg("missing data for
column \"%s\"",
-
NameStr(att->attname))));
- string = field_strings[fieldno++];
+ {
+ /*
+ * Some attributes are missing. In FILL MISSING
FIELDS mode,
+ * treat them as NULLs.
+ */
+ if (!cstate->opts.fill_missing)
+ ereport(ERROR,
+
(errcode(ERRCODE_BAD_COPY_FILE_FORMAT),
+
errmsg("missing data for column \"%s\"",
+
NameStr(att->attname))));
+ fieldno++;
+ string = NULL;
+ }
+ else
+ string = field_strings[fieldno++];
if (cstate->convert_select_flags &&
!cstate->convert_select_flags[m])
@@ -957,7 +1083,6 @@ NextCopyFrom(CopyFromState cstate, ExprContext *econtext,
cstate->cur_attname = NameStr(att->attname);
cstate->cur_attval = string;
-
if (string != NULL)
nulls[m] = false;
@@ -984,7 +1109,7 @@ NextCopyFrom(CopyFromState cstate, ExprContext *econtext,
Assert(fieldno == attr_count);
}
- else
+ else if (attr_count)
{
/* binary */
int16 fld_count;
@@ -1001,35 +1126,42 @@ NextCopyFrom(CopyFromState cstate, ExprContext
*econtext,
if (fld_count == -1)
{
/*
- * Received EOF marker. Wait for the protocol-level
EOF, and
- * complain if it doesn't come immediately. In COPY
FROM STDIN,
- * this ensures that we correctly handle CopyFail, if
client
- * chooses to send that now. When copying from file,
we could
- * ignore the rest of the file like in text mode, but
we choose to
- * be consistent with the COPY FROM STDIN case.
+ * Received EOF marker. In a V3-protocol copy, wait
for the
+ * protocol-level EOF, and complain if it doesn't come
+ * immediately. This ensures that we correctly handle
CopyFail,
+ * if client chooses to send that now.
+ *
+ * Note that we MUST NOT try to read more data in an
old-protocol
+ * copy, since there is no protocol-level EOF marker
then. We
+ * could go either way for copy from file, but choose
to throw
+ * error if there's data after the EOF marker, for
consistency
+ * with the new-protocol case.
*/
char dummy;
- if (CopyReadBinaryData(cstate, &dummy, 1) > 0)
+ if (cstate->copy_src != COPY_FRONTEND &&
+ CopyGetData(cstate, &dummy, 1, 1) > 0)
ereport(ERROR,
(errcode(ERRCODE_BAD_COPY_FILE_FORMAT),
- errmsg("received copy data
after EOF marker")));
+
errmsg("received copy data after EOF marker")));
return false;
}
if (fld_count != attr_count)
ereport(ERROR,
(errcode(ERRCODE_BAD_COPY_FILE_FORMAT),
- errmsg("row field count is %d,
expected %d",
- (int) fld_count,
attr_count)));
+ errmsg("row field count
is %d, expected %d",
+ (int)
fld_count, attr_count)));
- foreach(cur, cstate->attnumlist)
+ i = 0;
+ foreach(cur, attnumlist)
{
int attnum = lfirst_int(cur);
int m = attnum - 1;
Form_pg_attribute att = TupleDescAttr(tupDesc, m);
cstate->cur_attname = NameStr(att->attname);
+ i++;
values[m] = CopyReadBinaryAttribute(cstate,
&in_functions[m],
typioparams[m],
@@ -1043,23 +1175,33 @@ NextCopyFrom(CopyFromState cstate, ExprContext
*econtext,
* Now compute and insert any defaults available for the columns not
* provided by the input data. Anything not processed here or above
will
* remain NULL.
+ *
+ * GPDB: The defaults are always computed in the QD, and are included
+ * in the QD->QE stream as pre-computed Datums. Funny indentation, to
+ * keep the indentation of the code inside the same as in upstream.
+ * (We could improve this, and compute immutable defaults that don't
+ * affect which segment the row belongs to, in the QE.)
*/
- for (i = 0; i < num_defaults; i++)
+ if (cstate->dispatch_mode != COPY_EXECUTOR)
{
- /*
- * The caller must supply econtext and have switched into the
- * per-tuple memory context in it.
- */
- Assert(econtext != NULL);
- Assert(CurrentMemoryContext == econtext->ecxt_per_tuple_memory);
+ for (i = 0; i < num_defaults; i++)
+ {
+ /*
+ * The caller must supply econtext and have switched
into the
+ * per-tuple memory context in it.
+ */
+ Assert(econtext != NULL);
+ Assert(CurrentMemoryContext ==
econtext->ecxt_per_tuple_memory);
- values[defmap[i]] = ExecEvalExpr(defexprs[defmap[i]], econtext,
-
&nulls[defmap[i]]);
+ values[defmap[i]] = ExecEvalExpr(defexprs[defmap[i]],
econtext,
+
&nulls[defmap[i]]);
+ }
}
return true;
}
+
/*
* Read the next input line and stash it in line_buf.
*
diff --git a/src/backend/commands/createas.c b/src/backend/commands/createas.c
index e4ed2e71d23..0c2835fbe10 100644
--- a/src/backend/commands/createas.c
+++ b/src/backend/commands/createas.c
@@ -1818,7 +1818,7 @@ get_primary_key_attnos_from_query(Query *query, List
**constraintList)
i = 1;
foreach(lc, query->targetList)
{
- TargetEntry *tle = (TargetEntry *)
flatten_join_alias_vars(query, lfirst(lc));
+ TargetEntry *tle = (TargetEntry *)
flatten_join_alias_vars(NULL, query, lfirst(lc));
if (IsA(tle->expr, Var))
{
diff --git a/src/backend/commands/dirtablecmds.c
b/src/backend/commands/dirtablecmds.c
index 6f3bd94285e..bd2f6ba503d 100644
--- a/src/backend/commands/dirtablecmds.c
+++ b/src/backend/commands/dirtablecmds.c
@@ -98,8 +98,8 @@ chooseTableSpace(CreateDirectoryTableStmt *stmt)
{
AclResult aclresult;
- aclresult = pg_tablespace_aclcheck(tablespaceId, GetUserId(),
-
ACL_CREATE);
+ aclresult = object_aclcheck(TableSpaceRelationId, tablespaceId,
GetUserId(),
+
ACL_CREATE);
if (aclresult != ACLCHECK_OK)
aclcheck_error(aclresult, OBJECT_TABLESPACE,
get_tablespace_name(tablespaceId));
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index dbb17090e1d..670c4b85011 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -19331,7 +19331,7 @@ ATExecExpandTable(List **wqueue, Relation rel,
AlterTableCmd *cmd, int numsegmen
errmsg("EXPAND not supported in utility mode")));
/* Permissions checks */
- if (!pg_class_ownercheck(relid, GetUserId()))
+ if (!object_ownercheck(RelationRelationId, relid, GetUserId()))
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_TABLE,
RelationGetRelationName(rel));
diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c
index f8b081f279d..59fb8c4e3b8 100644
--- a/src/backend/commands/vacuum.c
+++ b/src/backend/commands/vacuum.c
@@ -2761,8 +2761,8 @@ vacuum_rel(Oid relid, RangeVar *relation, VacuumParams
*params,
* Note we choose to treat permissions failure as a WARNING and keep
* trying to vacuum the rest of the DB --- is this appropriate?
*/
- if (!(pg_class_ownercheck(RelationGetRelid(rel), GetUserId()) ||
- (pg_database_ownercheck(MyDatabaseId, GetUserId()) &&
!rel->rd_rel->relisshared)))
+ if (!(object_ownercheck(RelationRelationId, RelationGetRelid(rel),
GetUserId()) ||
+ (object_ownercheck(DatabaseRelationId, MyDatabaseId,
GetUserId()) && !rel->rd_rel->relisshared)))
{
if (Gp_role != GP_ROLE_EXECUTE)
{
diff --git a/src/backend/optimizer/path/costsize.c
b/src/backend/optimizer/path/costsize.c
index 2d54c863eac..b5be1ef3f1a 100644
--- a/src/backend/optimizer/path/costsize.c
+++ b/src/backend/optimizer/path/costsize.c
@@ -4152,7 +4152,7 @@ initial_cost_hashjoin(PlannerInfo *root,
JoinCostWorkspace *workspace,
ExecChooseHashTableSize(inner_path_rows_total,
inner_path->pathtarget->width,
true, /* useskew */
- get_hash_mem(),
+ get_hash_memory_limit(),
parallel_hash, /*
try_combined_hash_mem */
outer_path->parallel_workers,
&space_allowed,
diff --git a/src/backend/optimizer/path/joinrels.c
b/src/backend/optimizer/path/joinrels.c
index b8e37e7f60a..d4de56186ab 100644
--- a/src/backend/optimizer/path/joinrels.c
+++ b/src/backend/optimizer/path/joinrels.c
@@ -779,8 +779,8 @@ make_join_relation(PlannerInfo *root, RelOptInfo *rel1,
RelOptInfo *rel2)
* goes with this particular joining.
*/
joinrel = build_join_rel(root, joinrelids, rel1, rel2,
- sjinfo,
pushed_down_joins,
- &restrictlist, NULL);
+ sjinfo, &restrictlist,
pushed_down_joins,
+ NULL);
/*
* If we've already proven this join is empty, we needn't consider any
@@ -864,8 +864,8 @@ make_grouped_join_rel(PlannerInfo *root, RelOptInfo *rel1,
RelOptInfo *rel2,
agg_info->build_from_plain = true;
joinrel = agg_info->rel_grouped;
if (joinrel == NULL)
- joinrel = build_join_rel(root, joinrelids, rel1, rel2,
sjinfo, NIL,
-
&restrictlist, agg_info);
+ joinrel = build_join_rel(root, joinrelids, rel1, rel2,
sjinfo,
+
&restrictlist, NIL,agg_info);
generate_grouping_paths(root, joinrel, joinrel_plain, agg_info);
if (joinrel->pathlist != NIL || joinrel->partial_pathlist !=
NIL)
add_grouped_rel_agg_info(root, joinrel, agg_info);
@@ -906,8 +906,8 @@ make_grouped_join_rel(PlannerInfo *root, RelOptInfo *rel1,
RelOptInfo *rel2,
agg_info->build_from_plain = false;
joinrel = agg_info->rel_grouped_non_plain;
if (joinrel == NULL)
- joinrel = build_join_rel(root, joinrelids, rel1, rel2,
sjinfo, NIL,
-
&restrictlist, agg_info);
+ joinrel = build_join_rel(root, joinrelids, rel1, rel2,
sjinfo,
+
&restrictlist, NIL, agg_info);
populate_joinrel_with_paths(root, rel1, rel2, joinrel, sjinfo,
restrictlist);
diff --git a/src/backend/optimizer/plan/planner.c
b/src/backend/optimizer/plan/planner.c
index 06a247fe7d3..4e767aaea03 100644
--- a/src/backend/optimizer/plan/planner.c
+++ b/src/backend/optimizer/plan/planner.c
@@ -1259,7 +1259,7 @@ subquery_planner(PlannerGlobal *glob, Query *parse,
*/
if (rte->lateral && root->hasJoinRTEs)
rte->subquery = (Query *)
- flatten_join_alias_vars(root->parse,
+ flatten_join_alias_vars(root,
root->parse,
(Node *) rte->subquery);
}
else if (rte->rtekind == RTE_FUNCTION || rte->rtekind ==
RTE_TABLEFUNCTION)
@@ -1460,7 +1460,7 @@ preprocess_expression(PlannerInfo *root, Node *expr, int
kind)
kind == EXPRKIND_VALUES ||
kind == EXPRKIND_TABLESAMPLE ||
kind == EXPRKIND_TABLEFUNC))
- expr = flatten_join_alias_vars(root->parse, expr);
+ expr = flatten_join_alias_vars(root, root->parse, expr);
if (root->parse->hasFuncsWithExecRestrictions)
{
diff --git a/src/backend/optimizer/prep/prepjointree.c
b/src/backend/optimizer/prep/prepjointree.c
index 66d41ae5a9f..dde7402c572 100644
--- a/src/backend/optimizer/prep/prepjointree.c
+++ b/src/backend/optimizer/prep/prepjointree.c
@@ -1288,7 +1288,7 @@ pull_up_simple_subquery(PlannerInfo *root, Node *jtnode,
RangeTblEntry *rte,
* maybe even in the rewriter; but for now let's just fix this case
here.)
*/
subquery->targetList = (List *)
- flatten_join_alias_vars(subroot, subroot->parse,
+ flatten_join_alias_vars(root, subroot->parse,
(Node *)
subquery->targetList);
/*
diff --git a/src/backend/optimizer/util/clauses.c
b/src/backend/optimizer/util/clauses.c
index 4bfb238e82c..20a1c8a1d57 100644
--- a/src/backend/optimizer/util/clauses.c
+++ b/src/backend/optimizer/util/clauses.c
@@ -5738,35 +5738,35 @@ flatten_join_alias_var_optimizer(Query *query, int
queryLevel)
if (NIL != targetList)
{
/*.MERGE16_FIXME: We should not use null here */
- queryNew->targetList = (List *)
flatten_join_alias_vars(queryNew, (Node *) targetList);
+ queryNew->targetList = (List *) flatten_join_alias_vars(NULL,
queryNew, (Node *) targetList);
list_free(targetList);
}
List * returningList = queryNew->returningList;
if (NIL != returningList)
{
- queryNew->returningList = (List *)
flatten_join_alias_vars(queryNew, (Node *) returningList);
+ queryNew->returningList = (List *)
flatten_join_alias_vars(NULL, queryNew, (Node *) returningList);
list_free(returningList);
}
Node *havingQual = queryNew->havingQual;
if (NULL != havingQual)
{
- queryNew->havingQual = flatten_join_alias_vars(queryNew,
havingQual);
+ queryNew->havingQual = flatten_join_alias_vars(NULL, queryNew,
havingQual);
pfree(havingQual);
}
List *scatterClause = queryNew->scatterClause;
if (NIL != scatterClause)
{
- queryNew->scatterClause = (List *)
flatten_join_alias_vars(queryNew, (Node *) scatterClause);
+ queryNew->scatterClause = (List *)
flatten_join_alias_vars(NULL, queryNew, (Node *) scatterClause);
list_free(scatterClause);
}
Node *limitOffset = queryNew->limitOffset;
if (NULL != limitOffset)
{
- queryNew->limitOffset = flatten_join_alias_vars(queryNew,
limitOffset);
+ queryNew->limitOffset = flatten_join_alias_vars(NULL, queryNew,
limitOffset);
pfree(limitOffset);
}
@@ -5783,17 +5783,17 @@ flatten_join_alias_var_optimizer(Query *query, int
queryLevel)
continue;
if (wc->startOffset)
- wc->startOffset =
flatten_join_alias_vars(queryNew, wc->startOffset);
+ wc->startOffset = flatten_join_alias_vars(NULL,
queryNew, wc->startOffset);
if (wc->endOffset)
- wc->endOffset =
flatten_join_alias_vars(queryNew, wc->endOffset);
+ wc->endOffset = flatten_join_alias_vars(NULL,
queryNew, wc->endOffset);
}
}
Node *limitCount = queryNew->limitCount;
if (NULL != limitCount)
{
- queryNew->limitCount = flatten_join_alias_vars(queryNew,
limitCount);
+ queryNew->limitCount = flatten_join_alias_vars(NULL, queryNew,
limitCount);
pfree(limitCount);
}
diff --git a/src/backend/parser/parse_agg.c b/src/backend/parser/parse_agg.c
index 3177b2b032a..1669ef066b8 100644
--- a/src/backend/parser/parse_agg.c
+++ b/src/backend/parser/parse_agg.c
@@ -3,7 +3,7 @@
* parse_agg.c
* handle aggregates in parser
*
- * Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group
+ * Portioflatten_join_alias_varsns Copyright (c) 1996-2023, PostgreSQL Global
Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
*
@@ -1245,7 +1245,7 @@ parseCheckAggregates(ParseState *pstate, Query *qry)
* entries are RTE_JOIN kind.
*/
if (hasJoinRTEs)
- groupClauses = (List *) flatten_join_alias_vars(qry,
+ groupClauses = (List *) flatten_join_alias_vars(NULL, qry,
(Node *) groupClauses);
/*
@@ -1289,7 +1289,7 @@ parseCheckAggregates(ParseState *pstate, Query *qry)
groupClauses,
hasJoinRTEs,
have_non_var_grouping);
if (hasJoinRTEs)
- clause = flatten_join_alias_vars(qry, clause);
+ clause = flatten_join_alias_vars(NULL, qry, clause);
check_ungrouped_columns(clause, pstate, qry,
groupClauses,
groupClauseCommonVars,
have_non_var_grouping,
@@ -1300,7 +1300,7 @@ parseCheckAggregates(ParseState *pstate, Query *qry)
groupClauses,
hasJoinRTEs,
have_non_var_grouping);
if (hasJoinRTEs)
- clause = flatten_join_alias_vars(qry, clause);
+ clause = flatten_join_alias_vars(NULL, qry, clause);
check_ungrouped_columns(clause, pstate, qry,
groupClauses,
groupClauseCommonVars,
have_non_var_grouping,
@@ -1639,7 +1639,7 @@ finalize_grouping_exprs_walker(Node *node,
Index ref = 0;
if (context->hasJoinRTEs)
- expr =
flatten_join_alias_vars(context->qry, expr);
+ expr = flatten_join_alias_vars(NULL,
context->qry, expr);
/*
* Each expression must match a grouping entry
at the current
diff --git a/src/backend/postmaster/autostats.c
b/src/backend/postmaster/autostats.c
index 35bde52b459..20122f1b531 100644
--- a/src/backend/postmaster/autostats.c
+++ b/src/backend/postmaster/autostats.c
@@ -19,6 +19,7 @@
#include "postgres.h"
#include "catalog/catalog.h"
+#include "catalog/pg_database.h"
#include "cdb/cdbvars.h"
#include "commands/vacuum.h"
#include "executor/execdesc.h"
@@ -60,8 +61,8 @@ autostats_issue_analyze(Oid relationOid)
* If this user does not own the table, then auto-stats will
not issue the
* analyze. This check will be skipped if
gp_autostats_allow_nonowner=true
*/
- if (!(pg_class_ownercheck(relationOid, GetUserId()) ||
- (pg_database_ownercheck(MyDatabaseId, GetUserId()) &&
!IsSharedRelation(relationOid))))
+ if (!(object_ownercheck(RelationRelationId, relationOid,
GetUserId()) ||
+ (object_ownercheck(DatabaseRelationId, MyDatabaseId,
GetUserId()) && !IsSharedRelation(relationOid))))
{
if (log_autostats)
elog(LOG, "Auto-stats did not issue ANALYZE on
tableoid %d since the user does not have table-owner level permissions.",
diff --git a/src/include/commands/copy.h b/src/include/commands/copy.h
index 06681991b11..3de7c7831ae 100644
--- a/src/include/commands/copy.h
+++ b/src/include/commands/copy.h
@@ -174,6 +174,8 @@ extern bool NextCopyFrom(CopyFromState cstate, ExprContext
*econtext,
Datum *values, bool *nulls);
extern bool NextCopyFromRawFields(CopyFromState cstate,
char
***fields, int *nfields);
+extern bool NextCopyFromRawFieldsX(CopyFromState cstate, char ***fields, int
*nfields,
+ int
stop_processing_at_field);
extern void CopyFromErrorCallback(void *arg);
extern uint64 CopyFrom(CopyFromState cstate);
diff --git a/src/include/commands/copyfrom_internal.h
b/src/include/commands/copyfrom_internal.h
index c56671c1ea7..fb37016da29 100644
--- a/src/include/commands/copyfrom_internal.h
+++ b/src/include/commands/copyfrom_internal.h
@@ -214,6 +214,8 @@ extern Datum CopyReadBinaryAttribute(CopyFromState cstate,
FmgrInfo *flinfo,
extern int CopyGetData(CopyFromState cstate, void *databuf,
int minread, int maxread);
extern int CopyReadBinaryData(CopyFromState cstate, char *dest, int nbytes);
+extern bool NextCopyFromX(CopyFromState cstate, ExprContext *econtext,
+ Datum *values, bool *nulls);
/*
* These functions do apply some data conversion
diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h
index 87018b67077..830232432a3 100644
--- a/src/include/miscadmin.h
+++ b/src/include/miscadmin.h
@@ -611,7 +611,6 @@ extern void RestoreClientConnectionInfo(char *conninfo);
/* in executor/nodeHash.c */
extern size_t get_hash_memory_limit(void);
-extern int get_hash_mem(void);
/*
* In GPDB, some utility commands may execute nested in another utilities,
diff --git a/src/include/optimizer/optimizer.h
b/src/include/optimizer/optimizer.h
index 010d7ad7002..e3473ccca7d 100644
--- a/src/include/optimizer/optimizer.h
+++ b/src/include/optimizer/optimizer.h
@@ -204,7 +204,7 @@ extern bool contain_vars_of_level(Node *node, int levelsup);
extern bool contain_vars_of_level_or_above(Node *node, int levelsup);
extern int locate_var_of_level(Node *node, int levelsup);
extern List *pull_var_clause(Node *node, int flags);
-extern Node *flatten_join_alias_vars(Query *query, Node *node);
+extern Node *flatten_join_alias_vars(PlannerInfo *root, Query *query, Node
*node);
extern bool contain_ctid_var_reference(Scan *scan);
diff --git a/src/include/utils/acl.h b/src/include/utils/acl.h
index 2d79448f85a..1cb083068d8 100644
--- a/src/include/utils/acl.h
+++ b/src/include/utils/acl.h
@@ -263,8 +263,6 @@ extern AclResult pg_parameter_aclcheck(const char *name,
Oid roleid,
AclMode mode);
extern AclResult pg_largeobject_aclcheck_snapshot(Oid lobj_oid, Oid roleid,
AclMode mode, Snapshot snapshot);
-extern AclResult pg_namespace_aclcheck(Oid nsp_oid, Oid roleid, AclMode mode);
-extern AclResult pg_tablespace_aclcheck(Oid spc_oid, Oid roleid, AclMode mode);
extern AclResult gp_storage_server_aclcheck(Oid srv_oid, Oid roleid, AclMode
mode);
extern AclResult pg_extprotocol_aclcheck(Oid ptc_oid, Oid roleid, AclMode
mode);
@@ -282,31 +280,8 @@ extern void removeExtObjInitPriv(Oid objoid, Oid classoid);
/* ownercheck routines just return true (owner) or false (not) */
-extern bool pg_extension_ownercheck(Oid ext_oid, Oid roleid);
-extern bool pg_class_ownercheck(Oid class_oid, Oid roleid);
-extern bool pg_type_ownercheck(Oid type_oid, Oid roleid);
-extern bool pg_oper_ownercheck(Oid oper_oid, Oid roleid);
-extern bool pg_proc_ownercheck(Oid proc_oid, Oid roleid);
-extern bool pg_language_ownercheck(Oid lan_oid, Oid roleid);
-extern bool pg_largeobject_ownercheck(Oid lobj_oid, Oid roleid);
-extern bool pg_namespace_ownercheck(Oid nsp_oid, Oid roleid);
-extern bool pg_tablespace_ownercheck(Oid spc_oid, Oid roleid);
-extern bool pg_opclass_ownercheck(Oid opc_oid, Oid roleid);
-extern bool pg_opfamily_ownercheck(Oid opf_oid, Oid roleid);
-extern bool pg_database_ownercheck(Oid db_oid, Oid roleid);
-extern bool pg_collation_ownercheck(Oid coll_oid, Oid roleid);
-extern bool pg_conversion_ownercheck(Oid conv_oid, Oid roleid);
extern bool pg_tag_ownercheck(Oid tag_oid, Oid roleid);
-extern bool pg_ts_dict_ownercheck(Oid dict_oid, Oid roleid);
-extern bool pg_ts_config_ownercheck(Oid cfg_oid, Oid roleid);
-extern bool pg_foreign_data_wrapper_ownercheck(Oid srv_oid, Oid roleid);
-extern bool pg_foreign_server_ownercheck(Oid srv_oid, Oid roleid);
extern bool gp_storage_server_ownercheck(Oid srv_oid, Oid roleid);
-extern bool pg_event_trigger_ownercheck(Oid et_oid, Oid roleid);
-extern bool pg_extension_ownercheck(Oid ext_oid, Oid roleid);
-extern bool pg_publication_ownercheck(Oid pub_oid, Oid roleid);
-extern bool pg_subscription_ownercheck(Oid sub_oid, Oid roleid);
-extern bool pg_statistics_object_ownercheck(Oid stat_oid, Oid roleid);
extern bool object_ownercheck(Oid classid, Oid objectid, Oid roleid);
extern bool has_createrole_privilege(Oid roleid);
extern bool pg_extprotocol_ownercheck(Oid ptc_oid, Oid roleid);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]