Skip to content

Commit eb4b096

Browse files
authored
add ivorysql database and modify ivorysql version (#706)
* IvorySQL:Add default database ivorysql * IvorySQL:update IvorySQL regression test * IvorySQL:IvorySQL version 1.8
1 parent cfd0215 commit eb4b096

8 files changed

Lines changed: 58 additions & 26 deletions

File tree

configure

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2826,6 +2826,9 @@ cat >>confdefs.h <<_ACEOF
28262826
_ACEOF
28272827

28282828

2829+
# IvorySQL version
2830+
PACKAGE_IVORYSQL_VERSION='1.8'
2831+
28292832
PG_MAJORVERSION=`expr "$PACKAGE_VERSION" : '\([0-9][0-9]*\)'`
28302833
PG_MINORVERSION=`expr "$PACKAGE_VERSION" : '.*\.\([0-9][0-9]*\)'`
28312834
test -n "$PG_MINORVERSION" || PG_MINORVERSION=0
@@ -19999,7 +20002,7 @@ fi
1999920002

2000020003

2000120004
cat >>confdefs.h <<_ACEOF
20002-
#define PG_VERSION_STR "PostgreSQL $PG_VERSION on $host, compiled by $cc_string, `expr $ac_cv_sizeof_void_p \* 8`-bit"
20005+
#define PG_VERSION_STR "PostgreSQL $PG_VERSION (IvorySQL $PACKAGE_IVORYSQL_VERSION) on $host, compiled by $cc_string, `expr $ac_cv_sizeof_void_p \* 8`-bit"
2000320006
_ACEOF
2000420007

2000520008

configure.ac

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,17 @@ AC_CONFIG_AUX_DIR(config)
2929
AC_PREFIX_DEFAULT(/usr/local/pgsql)
3030
AC_DEFINE_UNQUOTED(CONFIGURE_ARGS, ["$ac_configure_args"], [Saved arguments from configure])
3131

32+
# IvorySQL version
33+
PACKAGE_IVORYSQL_VERSION='1.8'
34+
3235
[PG_MAJORVERSION=`expr "$PACKAGE_VERSION" : '\([0-9][0-9]*\)'`]
3336
[PG_MINORVERSION=`expr "$PACKAGE_VERSION" : '.*\.\([0-9][0-9]*\)'`]
3437
test -n "$PG_MINORVERSION" || PG_MINORVERSION=0
3538
AC_SUBST(PG_MAJORVERSION)
3639
AC_DEFINE_UNQUOTED(PG_MAJORVERSION, "$PG_MAJORVERSION", [PostgreSQL major version as a string])
3740
AC_DEFINE_UNQUOTED(PG_MAJORVERSION_NUM, $PG_MAJORVERSION, [PostgreSQL major version number])
3841
AC_DEFINE_UNQUOTED(PG_MINORVERSION_NUM, $PG_MINORVERSION, [PostgreSQL minor version number])
42+
AC_DEFINE([PACKAGE_IVORYSQL_VERSION], $PACKAGE_IVORYSQL_VERSION , [IvorySQL version number])
3943

4044
PGAC_ARG_REQ(with, extra-version, [STRING], [append STRING to version],
4145
[PG_VERSION="$PACKAGE_VERSION$withval"],
@@ -2432,7 +2436,7 @@ else
24322436
fi
24332437

24342438
AC_DEFINE_UNQUOTED(PG_VERSION_STR,
2435-
["PostgreSQL $PG_VERSION on $host, compiled by $cc_string, `expr $ac_cv_sizeof_void_p \* 8`-bit"],
2439+
["PostgreSQL $PG_VERSION (IvorySQL $PACKAGE_IVORYSQL_VERSION) on $host, compiled by $cc_string, `expr $ac_cv_sizeof_void_p \* 8`-bit"],
24362440
[A string containing the version number, platform, and C compiler])
24372441

24382442
# Supply a numeric version string for use by 3rd party add-ons

src/bin/initdb/initdb.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ static void load_ivorysql_ora(FILE *cmdfd);
290290
static void vacuum_db(FILE *cmdfd);
291291
static void make_template0(FILE *cmdfd);
292292
static void make_postgres(FILE *cmdfd);
293+
static void make_ivorysql(FILE *cmdfd);
293294
static void trapsig(int signum);
294295
static void check_ok(void);
295296
static char *escape_quotes(const char *src);
@@ -2086,6 +2087,23 @@ make_postgres(FILE *cmdfd)
20862087
PG_CMD_PUTS(*line);
20872088
}
20882089

2090+
/*
2091+
* copy template1 to ivorysql
2092+
*/
2093+
static void
2094+
make_ivorysql(FILE *cmdfd)
2095+
{
2096+
const char *const *line;
2097+
static const char *const ivorysql_setup[] = {
2098+
"CREATE DATABASE ivorysql;\n\n",
2099+
"COMMENT ON DATABASE postgres IS 'default administrative connection database';\n\n",
2100+
NULL
2101+
};
2102+
2103+
for (line = ivorysql_setup; *line; line++)
2104+
PG_CMD_PUTS(*line);
2105+
}
2106+
20892107
/*
20902108
* signal handler in case we are interrupted.
20912109
*
@@ -3082,6 +3100,8 @@ initialize_data_directory(void)
30823100

30833101
make_postgres(cmdfd);
30843102

3103+
make_ivorysql(cmdfd);
3104+
30853105
PG_CMD_CLOSE;
30863106

30873107
check_ok();

src/bin/pg_dump/pg_dumpall.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1349,12 +1349,13 @@ dropDBs(PGconn *conn)
13491349
char *dbname = PQgetvalue(res, i, 0);
13501350

13511351
/*
1352-
* Skip "postgres" and "template1"; dumpDatabases() will deal with
1352+
* Skip "postgres", "ivorysql" and "template1"; dumpDatabases() will deal with
13531353
* them specially. Also, be sure to skip "template0", even if for
13541354
* some reason it's not marked !datallowconn.
13551355
*/
13561356
if (strcmp(dbname, "template1") != 0 &&
13571357
strcmp(dbname, "template0") != 0 &&
1358+
strcmp(dbname, "ivorysql") != 0 &&
13581359
strcmp(dbname, "postgres") != 0)
13591360
{
13601361
fprintf(OPF, "DROP DATABASE %s%s;\n",
@@ -1530,14 +1531,16 @@ dumpDatabases(PGconn *conn)
15301531
fprintf(OPF, "--\n-- Database \"%s\" dump\n--\n\n", dbname);
15311532

15321533
/*
1533-
* We assume that "template1" and "postgres" already exist in the
1534+
* We assume that "template1", "ivorysql" and "postgres" already exist in the
15341535
* target installation. dropDBs() won't have removed them, for fear
15351536
* of removing the DB the restore script is initially connected to. If
15361537
* --clean was specified, tell pg_dump to drop and recreate them;
15371538
* otherwise we'll merely restore their contents. Other databases
15381539
* should simply be created.
15391540
*/
1540-
if (strcmp(dbname, "template1") == 0 || strcmp(dbname, "postgres") == 0)
1541+
if (strcmp(dbname, "template1") == 0 ||
1542+
strcmp(dbname, "postgres") == 0 ||
1543+
strcmp(dbname, "ivorysql") == 0)
15411544
{
15421545
if (output_clean)
15431546
create_opts = "--clean --create";

src/bin/pg_rewind/t/002_databases.pl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ sub run_test
4949
'SELECT datname FROM pg_database ORDER BY 1',
5050
qq(beforepromotion
5151
inprimary
52+
ivorysql
5253
postgres
5354
standby_afterpromotion
5455
template0

src/bin/pg_upgrade/pg_upgrade.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,11 +386,12 @@ create_new_objects(void)
386386
snprintf(log_file_name, sizeof(log_file_name), DB_DUMP_LOG_FILE_MASK, old_db->db_oid);
387387

388388
/*
389-
* postgres database will already exist in the target installation, so
389+
* postgres database and ivorysql database will already exist in the target installation, so
390390
* tell pg_restore to drop and recreate it; otherwise we would fail to
391391
* propagate its database-level properties.
392392
*/
393-
if (strcmp(old_db->db_name, "postgres") == 0)
393+
if (strcmp(old_db->db_name, "postgres") == 0 ||
394+
strcmp(old_db->db_name, "ivorysql") == 0)
394395
create_opts = "--clean --create";
395396
else
396397
create_opts = "--create";

src/bin/psql/startup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ main(int argc, char *argv[])
256256
values[3] = password;
257257
keywords[4] = "dbname"; /* see do_connect() */
258258
values[4] = (options.list_dbs && options.dbname == NULL) ?
259-
"postgres" : options.dbname;
259+
"ivorysql" : options.dbname;
260260
keywords[5] = "fallback_application_name";
261261
values[5] = pset.progname;
262262
keywords[6] = "client_encoding";

src/oracle_test/regress/expected/compression.out

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,10 @@ CREATE TABLE cmdata2 (f1 int);
144144

145145
ALTER TABLE cmdata2 ALTER COLUMN f1 TYPE varchar;
146146
\d+ cmdata2
147-
Table "public.cmdata2"
148-
Column | Type | Collation | Nullable | Default | Storage | Compression | Stats target | Description
149-
--------+-------------------+-----------+----------+---------+----------+-------------+--------------+-------------
150-
f1 | character varying | | | | extended | | |
147+
Table "public.cmdata2"
148+
Column | Type | Collation | Nullable | Default | Storage | Compression | Stats target | Description
149+
--------+----------------+-----------+----------+---------+----------+-------------+--------------+-------------
150+
f1 | varchar2(4000) | | | | extended | | |
151151

152152
ALTER TABLE cmdata2 ALTER COLUMN f1 TYPE int USING f1::integer;
153153
\d+ cmdata2
@@ -161,24 +161,24 @@ ALTER TABLE cmdata2 ALTER COLUMN f1 TYPE int USING f1::integer;
161161
ALTER TABLE cmdata2 ALTER COLUMN f1 TYPE varchar;
162162
ALTER TABLE cmdata2 ALTER COLUMN f1 SET COMPRESSION pglz;
163163
\d+ cmdata2
164-
Table "public.cmdata2"
165-
Column | Type | Collation | Nullable | Default | Storage | Compression | Stats target | Description
166-
--------+-------------------+-----------+----------+---------+----------+-------------+--------------+-------------
167-
f1 | character varying | | | | extended | pglz | |
164+
Table "public.cmdata2"
165+
Column | Type | Collation | Nullable | Default | Storage | Compression | Stats target | Description
166+
--------+----------------+-----------+----------+---------+----------+-------------+--------------+-------------
167+
f1 | varchar2(4000) | | | | extended | pglz | |
168168

169169
ALTER TABLE cmdata2 ALTER COLUMN f1 SET STORAGE plain;
170170
\d+ cmdata2
171-
Table "public.cmdata2"
172-
Column | Type | Collation | Nullable | Default | Storage | Compression | Stats target | Description
173-
--------+-------------------+-----------+----------+---------+---------+-------------+--------------+-------------
174-
f1 | character varying | | | | plain | pglz | |
171+
Table "public.cmdata2"
172+
Column | Type | Collation | Nullable | Default | Storage | Compression | Stats target | Description
173+
--------+----------------+-----------+----------+---------+---------+-------------+--------------+-------------
174+
f1 | varchar2(4000) | | | | plain | pglz | |
175175

176176
INSERT INTO cmdata2 VALUES (repeat('123456789', 800));
177+
ERROR: value too long for type varchar2(4000 byte)
177178
SELECT pg_column_compression(f1) FROM cmdata2;
178179
pg_column_compression
179180
-----------------------
180-
181-
(1 row)
181+
(0 rows)
182182

183183
-- test compression with materialized view
184184
CREATE MATERIALIZED VIEW compressmv(x) AS SELECT * FROM cmdata1;
@@ -262,10 +262,10 @@ SELECT pg_column_compression(f1) FROM cmdata;
262262

263263
ALTER TABLE cmdata2 ALTER COLUMN f1 SET COMPRESSION default;
264264
\d+ cmdata2
265-
Table "public.cmdata2"
266-
Column | Type | Collation | Nullable | Default | Storage | Compression | Stats target | Description
267-
--------+-------------------+-----------+----------+---------+---------+-------------+--------------+-------------
268-
f1 | character varying | | | | plain | | |
265+
Table "public.cmdata2"
266+
Column | Type | Collation | Nullable | Default | Storage | Compression | Stats target | Description
267+
--------+----------------+-----------+----------+---------+---------+-------------+--------------+-------------
268+
f1 | varchar2(4000) | | | | plain | | |
269269

270270
-- test alter compression method for materialized views
271271
ALTER MATERIALIZED VIEW compressmv ALTER COLUMN x SET COMPRESSION lz4;

0 commit comments

Comments
 (0)