导出时设置GUC参数 behavior_compat_options
This commit is contained in:
@ -203,6 +203,7 @@ static ParallelStateEntry* GetMyPSEntry(ParallelState* pstate);
|
||||
static void archive_close_connection(int code, void* arg);
|
||||
static void take_down_nsname_in_drop_stmt(const char *stmt, char *result, int len);
|
||||
static void get_role_password(RestoreOptions* opts);
|
||||
static char* GetBehaviorCompatOptions(ArchiveHandle* fout);
|
||||
|
||||
/*
|
||||
* Wrapper functions.
|
||||
@ -2835,6 +2836,11 @@ static void _doSetFixedOutputState(ArchiveHandle* AH)
|
||||
if (findDBCompatibility(&AH->publicArc, PQdb(GetConnection(&AH->publicArc))) && hasSpecificExtension(&AH->publicArc, "dolphin"))
|
||||
(void)ahprintf(AH, "SET dolphin.sql_mode = 'sql_mode_full_group,pipes_as_concat,ansi_quotes,pad_char_to_full_length';\n");
|
||||
|
||||
/* set behavior_compat_options */
|
||||
char* compatOptions = GetBehaviorCompatOptions(AH);
|
||||
(void)ahprintf(AH, "SET behavior_compat_options = '%s';\n", compatOptions);
|
||||
free(compatOptions);
|
||||
|
||||
(void)ahprintf(AH, "\n");
|
||||
}
|
||||
|
||||
@ -5292,4 +5298,21 @@ bool hasSpecificExtension(Archive* fout, const char* extensionName)
|
||||
PQclear(res);
|
||||
destroyPQExpBuffer(query);
|
||||
return ntups != 0;
|
||||
}
|
||||
|
||||
static char* GetBehaviorCompatOptions(ArchiveHandle* fout)
|
||||
{
|
||||
char* val = NULL;
|
||||
PGresult* res = PQexec(fout->connection, "show behavior_compat_options;");
|
||||
|
||||
if (res != NULL && PQresultStatus(res) == PGRES_TUPLES_OK) {
|
||||
val = gs_strdup(PQgetvalue(res, 0, 0));
|
||||
} else {
|
||||
val = gs_strdup("");
|
||||
}
|
||||
|
||||
PQclear(res);
|
||||
res = NULL;
|
||||
|
||||
return val;
|
||||
}
|
30
src/test/regress/input/test_float_dump.source
Normal file
30
src/test/regress/input/test_float_dump.source
Normal file
@ -0,0 +1,30 @@
|
||||
create database test_float_dump;
|
||||
\c test_float_dump
|
||||
set search_path to test_float_dump;
|
||||
|
||||
\c postgres
|
||||
ALTER DATABASE test_float_dump SET behavior_compat_options TO 'float_as_numeric';
|
||||
|
||||
\c test_float_dump
|
||||
show behavior_compat_options;
|
||||
set behavior_compat_options = 'float_as_numeric';
|
||||
|
||||
create table test_float (c1 int, c2 float);
|
||||
insert into test_float values (1, 3.14);
|
||||
insert into test_float values (2, 1.79E+10);
|
||||
insert into test_float values (3, -0.01);
|
||||
select * from test_float order by c1;
|
||||
|
||||
\! @abs_bindir@/gs_dump test_float_dump -p @portstring@ -f @abs_bindir@/test_float_dump.sql -F p -w >/dev/null 2>&1; echo $?
|
||||
|
||||
drop table test_float;
|
||||
\d
|
||||
|
||||
\! @abs_bindir@/gsql -d test_float_dump -p @portstring@ -f @abs_bindir@/test_float_dump.sql;
|
||||
|
||||
select * from test_float order by c1;
|
||||
|
||||
drop table test_float;
|
||||
|
||||
\c postgres
|
||||
drop database test_float_dump;
|
@ -80,6 +80,7 @@ SET
|
||||
SET
|
||||
SET
|
||||
SET
|
||||
SET
|
||||
CREATE SCHEMA
|
||||
ALTER SCHEMA
|
||||
SET
|
||||
|
@ -44,6 +44,7 @@ SET
|
||||
SET
|
||||
SET
|
||||
SET
|
||||
SET
|
||||
CREATE FUNCTION
|
||||
ALTER FUNCTION
|
||||
CREATE EVENT TRIGGER
|
||||
|
@ -115,6 +115,7 @@ select usename from pg_user where usesysid = (select proowner from pg_proc wher
|
||||
--? .*
|
||||
--? .*
|
||||
--? .*
|
||||
--? .*
|
||||
\c mysqltestbak
|
||||
\sf proc_definer1
|
||||
CREATE DEFINER = testusr1 PROCEDURE public.proc_definer1()
|
||||
|
@ -112,6 +112,7 @@ SET
|
||||
SET
|
||||
SET
|
||||
SET
|
||||
SET
|
||||
CREATE SCHEMA
|
||||
ALTER SCHEMA
|
||||
SET
|
||||
|
64
src/test/regress/output/test_float_dump.source
Normal file
64
src/test/regress/output/test_float_dump.source
Normal file
@ -0,0 +1,64 @@
|
||||
create database test_float_dump;
|
||||
\c test_float_dump
|
||||
set search_path to test_float_dump;
|
||||
\c postgres
|
||||
ALTER DATABASE test_float_dump SET behavior_compat_options TO 'float_as_numeric';
|
||||
\c test_float_dump
|
||||
show behavior_compat_options;
|
||||
behavior_compat_options
|
||||
-------------------------
|
||||
float_as_numeric
|
||||
(1 row)
|
||||
|
||||
set behavior_compat_options = 'float_as_numeric';
|
||||
create table test_float (c1 int, c2 float);
|
||||
insert into test_float values (1, 3.14);
|
||||
insert into test_float values (2, 1.79E+10);
|
||||
insert into test_float values (3, -0.01);
|
||||
select * from test_float order by c1;
|
||||
c1 | c2
|
||||
----+-------------
|
||||
1 | 3.14
|
||||
2 | 17900000000
|
||||
3 | -.01
|
||||
(3 rows)
|
||||
|
||||
\! @abs_bindir@/gs_dump test_float_dump -p @portstring@ -f @abs_bindir@/test_float_dump.sql -F p -w >/dev/null 2>&1; echo $?
|
||||
0
|
||||
drop table test_float;
|
||||
\d
|
||||
List of relations
|
||||
Schema | Name | Type | Owner | Storage
|
||||
--------+------+------+-------+---------
|
||||
(0 rows)
|
||||
|
||||
\! @abs_bindir@/gsql -d test_float_dump -p @portstring@ -f @abs_bindir@/test_float_dump.sql;
|
||||
SET
|
||||
SET
|
||||
SET
|
||||
SET
|
||||
SET
|
||||
SET
|
||||
SET
|
||||
SET
|
||||
SET
|
||||
SET
|
||||
SET
|
||||
CREATE TABLE
|
||||
ALTER TABLE
|
||||
REVOKE
|
||||
REVOKE
|
||||
GRANT
|
||||
GRANT
|
||||
--?.*
|
||||
select * from test_float order by c1;
|
||||
c1 | c2
|
||||
----+-------------
|
||||
1 | 3.14
|
||||
2 | 17900000000
|
||||
3 | -.01
|
||||
(3 rows)
|
||||
|
||||
drop table test_float;
|
||||
\c postgres
|
||||
drop database test_float_dump;
|
@ -157,6 +157,7 @@ SET
|
||||
SET
|
||||
SET
|
||||
SET
|
||||
SET
|
||||
CREATE TABLE
|
||||
ALTER TABLE
|
||||
CREATE VIEW
|
||||
|
@ -472,7 +472,7 @@ test: select_into subselect_part2 gs_aggregate
|
||||
test: holdable_cursor cursor_expression cursor_expression_dump
|
||||
#test: portals_p2 window tsearch temp__6 col_subplan_base_2
|
||||
|
||||
test: test_float test_numeric_with_neg_scale
|
||||
test: test_float test_numeric_with_neg_scale test_float_dump
|
||||
|
||||
test: alter_table_000 alter_table_002 alter_table_003 alter_table_modify
|
||||
#test: alter_table_001 alter_table_modify_ustore
|
||||
|
Reference in New Issue
Block a user