Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert float8 with double instead of long double #826

Merged
merged 15 commits into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions contrib/formatter_fixedwidth/data/fixedwidth_encoding_GBK.tbl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
一二三四五六七八九十
一二三四五六七八九十
一二三四五六七八九十
一二三四五六七八九十
一二三四五六七八九十
一二三四五六七八九十
一二三四五六七八九十
一二三四五六七八九十
一二三四五六七八九十
一二三四五六七八九十
8 changes: 8 additions & 0 deletions contrib/formatter_fixedwidth/input/readable_query36.source
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
-- GBK encoding test file
DROP EXTERNAL TABLE IF EXISTS tbl_ext_fixedwidth;
CREATE READABLE EXTERNAL TABLE tbl_ext_fixedwidth (
s1 char(10), s2 text)
LOCATION ('file://@hostname@@abs_srcdir@/data//fixedwidth_encoding_GBK.tbl')
FORMAT 'CUSTOM' (formatter='fixedwidth_in', s1=10, s2=10) ENCODING 'GBK';

SELECT * FROM tbl_ext_fixedwidth ORDER BY s1;
21 changes: 21 additions & 0 deletions contrib/formatter_fixedwidth/output/readable_query36.source
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
-- GBK encoding test file
DROP EXTERNAL TABLE IF EXISTS tbl_ext_fixedwidth;
CREATE READABLE EXTERNAL TABLE tbl_ext_fixedwidth (
s1 char(10), s2 text)
LOCATION ('file://@hostname@@abs_srcdir@/data//fixedwidth_encoding_GBK.tbl')
FORMAT 'CUSTOM' (formatter='fixedwidth_in', s1=10, s2=10) ENCODING 'GBK';
SELECT * FROM tbl_ext_fixedwidth ORDER BY s1;
s1 | s2
-----------------+------------
涓�浜屼笁鍥涗簲 | 鍏竷鍏節鍗�
涓�浜屼笁鍥涗簲 | 鍏竷鍏節鍗�
涓�浜屼笁鍥涗簲 | 鍏竷鍏節鍗�
涓�浜屼笁鍥涗簲 | 鍏竷鍏節鍗�
涓�浜屼笁鍥涗簲 | 鍏竷鍏節鍗�
涓�浜屼笁鍥涗簲 | 鍏竷鍏節鍗�
涓�浜屼笁鍥涗簲 | 鍏竷鍏節鍗�
涓�浜屼笁鍥涗簲 | 鍏竷鍏節鍗�
涓�浜屼笁鍥涗簲 | 鍏竷鍏節鍗�
涓�浜屼笁鍥涗簲 | 鍏竷鍏節鍗�
(10 rows)

30 changes: 25 additions & 5 deletions gpAux/client/scripts/greenplum_clients_path.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,27 @@
GPHOME_CLIENTS=`pwd`
if test -n "${ZSH_VERSION:-}"; then
# zsh
SCRIPT_PATH="${(%):-%x}"
elif test -n "${BASH_VERSION:-}"; then
# bash
SCRIPT_PATH="${BASH_SOURCE[0]}"
else
# Unknown shell, hope below works.
# Tested with dash
result=$(lsof -p $$ -Fn | tail --lines=1 | xargs --max-args=2 | cut --delimiter=' ' --fields=2)
SCRIPT_PATH=${result#n}
fi

if test -z "$SCRIPT_PATH"; then
echo "The shell cannot be identified. \$GPHOME_CLIENTS may not be set correctly." >&2
fi
SCRIPT_DIR="$(cd "$(dirname "${SCRIPT_PATH}")" >/dev/null 2>&1 && pwd)"

if [ ! -L "${SCRIPT_DIR}" ]; then
GPHOME_CLIENTS=${SCRIPT_DIR}
else
GPHOME_CLIENTS=$(readlink "${SCRIPT_DIR}")
fi

PATH=${GPHOME_CLIENTS}/bin:${PATH}
PYTHONPATH=${GPHOME_CLIENTS}/bin/ext:${PYTHONPATH}

Expand All @@ -19,8 +42,5 @@ else
fi

if [ "$1" != "-q" ]; then
type python >/dev/null 2>&1
if [ $? -ne 0 ]; then
echo "Warning: Python not found. Python-2.5.1 or better is required to run gpload."
fi
command -v python3 >/dev/null || echo "Warning: Python 3 not found, which is required to run gpload."
fi
2 changes: 1 addition & 1 deletion gpMgmt/bin/gpexpand
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ status_detail_table_sql = """CREATE TABLE gpexpand.status_detail
status text,
expansion_started timestamp,
expansion_finished timestamp,
source_bytes numeric ) """
source_bytes numeric ) distributed by (table_oid)"""
# gpexpand views
progress_view_simple_sql = """CREATE VIEW gpexpand.expansion_progress AS
SELECT
Expand Down
24 changes: 24 additions & 0 deletions gpMgmt/test/behave/mgmt_utils/gprecoverseg.feature
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,30 @@ Feature: gprecoverseg tests
And the segments are synchronized
And check segment conf: postgresql.conf

Scenario: gprecoverseg full recovery displays pg_controldata success info
Given the database is running
And all the segments are running
And the segments are synchronized
And user stops all mirror processes
When user can start transactions
And the user runs "gprecoverseg -F -a"
Then gprecoverseg should return a return code of 0
And gprecoverseg should print "Successfully finished pg_controldata.* for dbid.*" to stdout
And the segments are synchronized
And check segment conf: postgresql.conf

Scenario: gprecoverseg incremental recovery displays pg_controldata success info
Given the database is running
And all the segments are running
And the segments are synchronized
And user stops all mirror processes
When user can start transactions
And the user runs "gprecoverseg -a"
Then gprecoverseg should return a return code of 0
And gprecoverseg should print "Successfully finished pg_controldata.* for dbid.*" to stdout
And the segments are synchronized
And check segment conf: postgresql.conf

Scenario: gprecoverseg mixed recovery displays pg_basebackup and rewind progress to the user
Given the database is running
And all the segments are running
Expand Down
6 changes: 5 additions & 1 deletion gpcontrib/gp_exttable_fdw/extaccess.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,10 @@ external_beginscan(Relation relation, uint32 scancounter,
* don't append to entry->options directly, we only store the encoding in
* entry->encoding (and ftoptions)
*/
if (fmttype_is_custom(fmtType))
{
extOptions = NIL;
}
extOptions = appendCopyEncodingOption(list_copy(extOptions), encoding);

/*
Expand All @@ -283,7 +287,7 @@ external_beginscan(Relation relation, uint32 scancounter,
external_getdata_callback,
(void *) scan,
NIL,
(fmttype_is_custom(fmtType) ? NIL : extOptions));
extOptions);

if (scan->fs_pstate->opts.header_line && Gp_role == GP_ROLE_DISPATCH)
{
Expand Down
10 changes: 3 additions & 7 deletions src/backend/access/appendonly/appendonlyam_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -1437,7 +1437,6 @@ appendonly_relation_copy_for_cluster(Relation OldHeap, Relation NewHeap,
for (;;)
{
HeapTuple tuple;
uint32 prev_memtuple_len = 0;
uint32 len;
uint32 null_save_len;
bool has_nulls;
Expand All @@ -1451,17 +1450,14 @@ appendonly_relation_copy_for_cluster(Relation OldHeap, Relation NewHeap,
heap_deform_tuple(tuple, oldTupDesc, values, isnull);

len = compute_memtuple_size(mt_bind, values, isnull, &null_save_len, &has_nulls);
if (len > prev_memtuple_len)
if (len > 0)
{
/* Here we are trying to avoid reallocation of temp mtuple */
if (mtuple != NULL)
pfree(mtuple);
mtuple = palloc(len);
prev_memtuple_len = len;
mtuple = NULL;
}

memtuple_form_to(mt_bind, values, isnull, len, null_save_len, has_nulls,
mtuple);
mtuple = memtuple_form_to(mt_bind, values, isnull, len, null_save_len, has_nulls, mtuple);

appendonly_insert(aoInsertDesc, mtuple, &aoTupleId);
}
Expand Down
31 changes: 20 additions & 11 deletions src/backend/access/common/memtuple.c
Original file line number Diff line number Diff line change
Expand Up @@ -612,30 +612,28 @@ memtuple_form(MemTupleBinding *pbind, Datum *values, bool *isnull)
uint32 len;
uint32 null_save_len;
bool has_nulls;
MemTuple result;

len = compute_memtuple_size(pbind, values, isnull, &null_save_len, &has_nulls);

result = palloc(len);

memtuple_form_to(pbind, values, isnull, len, null_save_len, has_nulls,
result);

return result;
return memtuple_form_to(pbind, values, isnull, len, null_save_len, has_nulls, NULL);
}


/*
* Form a memtuple from values and isnull, to a prespecified buffer
* Form a memtuple from values and isnull, to a prespecified buffer 'mtup'. This
* can act as an alternative to memtuple_form(), when we want close control over
* the memory allocation for the memtuple.
*
* You must call compute_memtuple_size() before this, and verify that
* the buffer is large enough. Pass through the 'len', 'null_save_len'
* and 'hasnull' values that compute_memtuple_size() returned.
*
* The tuple is written to 'mtup', which must be large enough to hold
* 'len' bytes.
* 'len' bytes. In case 'mtup' is NULL, the tuple is palloced.
*
* Returns 'mtup'.
*/
void
MemTuple
memtuple_form_to(MemTupleBinding *pbind,
Datum *values,
bool *isnull,
Expand All @@ -653,7 +651,16 @@ memtuple_form_to(MemTupleBinding *pbind,

colbind = (len <= MEMTUPLE_LEN_FITSHORT) ? &pbind->bind : &pbind->large_bind;

memset(mtup, 0, len);
if (mtup != NULL)
{
/*
* Use memset instead of the MemSet macro (optimized for word-aligned structures)
* here as MemTuple may not be word-aligned due to its variable member PRIVATE_mt_bits.
*/
memset(mtup, 0, len);
}
else
mtup = palloc0(len);

/* Set mtlen, this set the lead bit, len, and clears hasnull bit
* because the len returned from compute size is always max aligned
Expand Down Expand Up @@ -834,6 +841,8 @@ memtuple_form_to(MemTupleBinding *pbind,

if (hasext)
memtuple_set_hasext(mtup);

return mtup;
}

bool memtuple_attisnull(MemTuple mtup, MemTupleBinding *pbind, int attnum)
Expand Down
26 changes: 23 additions & 3 deletions src/backend/cdb/endpoint/cdbendpointretrieve.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include "utils/elog.h"
#include "utils/faultinjector.h"
#include "utils/guc.h"
#include "utils/typcache.h"
#include "cdbendpoint_private.h"
#include "cdb/cdbendpoint.h"
#include "cdb/cdbsrlz.h"
Expand Down Expand Up @@ -132,6 +133,7 @@ static void retrieve_subxact_callback(SubXactEvent event,
SubTransactionId parentSubid,
void *arg);
static TupleTableSlot *retrieve_next_tuple(void);
static void retrieve_conn_detach(dsm_segment *segment, Datum datum);

/*
* AuthEndpoint - Authenticate for retrieve connection.
Expand Down Expand Up @@ -356,8 +358,17 @@ start_retrieve(const char *endpointName)
if (!found)
attach_receiver_mq(handle);

if (CurrentSession->segment != NULL &&
dsm_segment_handle(CurrentSession->segment) != endpoint->sessionDsmHandle)
{
DetachSession();
}

if (CurrentSession->segment == NULL)
{
AttachSession(endpoint->sessionDsmHandle);
on_dsm_detach(CurrentSession->segment, &retrieve_conn_detach, (Datum) 0);
}
}

/*
Expand Down Expand Up @@ -779,10 +790,10 @@ retrieve_xact_callback(XactEvent ev, void *arg pg_attribute_unused())
finish_retrieve(true);

}
}

if (CurrentSession != NULL && CurrentSession->segment != NULL)
DetachSession();
if (CurrentSession != NULL && CurrentSession->segment != NULL)
DetachSession();
}
}

/*
Expand All @@ -797,3 +808,12 @@ retrieve_subxact_callback(SubXactEvent event,
if (event == SUBXACT_EVENT_ABORT_SUB)
retrieve_xact_callback(XACT_EVENT_ABORT, NULL);
}

/*
* Reset record cache when detach session.
*/
static void
retrieve_conn_detach(dsm_segment *segment, Datum datum)
{
reset_record_cache();
}
14 changes: 13 additions & 1 deletion src/backend/executor/execProcnode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1493,7 +1493,19 @@ ExecSetTupleBound(int64 tuples_needed, PlanState *child_node)
* that condition succeeds it affects nothing, while if it fails, no
* rows will be demanded from the Result child anyway.
*/
if (outerPlanState(child_node))

/*
* GPDB: The second condition ensures qual is empty.
* In case the RESULT node has a filter,
* we do not want to push down the tuple bound.
* This is because the bound will be applied before the filter,
* and could lead to a subset of the actual result being returned.
* Postgres doesn't create RESULT node with quals,
* whereas GPDB can, hence the deviation.
* See ExecResult() and create_projection_path_with_quals().
*/

if (outerPlanState(child_node) && child_node->plan->qual == NULL)
ExecSetTupleBound(tuples_needed, outerPlanState(child_node));
}
else if (IsA(child_node, SubqueryScanState))
Expand Down
11 changes: 8 additions & 3 deletions src/backend/fts/ftsmessagehandler.c
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,8 @@ HandleFtsWalRepPromote(void)
* idempotent way.
*/
DBState state = GetCurrentDBState();
if (state == DB_IN_ARCHIVE_RECOVERY)
XLogRecPtr redo = GetRedoRecPtr();
if (state == DB_IN_ARCHIVE_RECOVERY && redo != InvalidXLogRecPtr)
{
/*
* Reset sync_standby_names on promotion. This is to avoid commits
Expand All @@ -428,8 +429,12 @@ HandleFtsWalRepPromote(void)
}
else
{
elog(LOG, "ignoring promote request, walreceiver not running,"
" DBState = %d", state);
/*
* FTS will retry promotion request based on am_mirror reporting
* status.
*/
elog(LOG, "ignoring promote request, not in archive recovery state,"
" DBState = %d, RedoPtr = %X/%X", state, (uint32) (redo >> 32), (uint32) redo);
}

#ifndef USE_INTERNAL_FTS
Expand Down
4 changes: 4 additions & 0 deletions src/backend/fts/test/ftsmessagehandler_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
/* Actual function body */
#include "../ftsmessagehandler.c"

static XLogRecPtr fakeRedoRecPtr = 8948;

static void
expectSendFtsResponse(const QueryCompletion *qc, const FtsResponse *expectedResponse)
{
Expand Down Expand Up @@ -174,6 +176,7 @@ test_HandleFtsWalRepPromoteMirror(void **state)
am_mirror = true;

will_return(GetCurrentDBState, DB_IN_ARCHIVE_RECOVERY);
will_return(GetRedoRecPtr, &fakeRedoRecPtr);
will_be_called(UnsetSyncStandbysDefined);
will_be_called(SignalPromote);

Expand Down Expand Up @@ -213,6 +216,7 @@ test_HandleFtsWalRepPromotePrimary(void **state)
am_mirror = false;

will_return(GetCurrentDBState, DB_IN_PRODUCTION);
will_return(GetRedoRecPtr, &fakeRedoRecPtr);

FtsResponse mockresponse;
mockresponse.IsMirrorUp = false;
Expand Down
9 changes: 9 additions & 0 deletions src/backend/tcop/utility.c
Original file line number Diff line number Diff line change
Expand Up @@ -4639,6 +4639,15 @@ GetCommandLogLevel(Node *parsetree)
}
break;

case T_CreateResourceGroupStmt:
case T_AlterResourceGroupStmt:
case T_DropResourceGroupStmt:
case T_CreateQueueStmt:
case T_AlterQueueStmt:
case T_DropQueueStmt:
lev = LOGSTMT_DDL;
break;

default:
elog(WARNING, "unrecognized node type: %d",
(int) nodeTag(parsetree));
Expand Down
Loading
Loading