mirror of
https://github.com/postgres/postgres.git
synced 2025-07-26 00:02:13 -04:00
Compare commits
3 Commits
ff68cc6f3b
...
414e75540f
Author | SHA1 | Date | |
---|---|---|---|
|
414e75540f | ||
|
1db5300015 | ||
|
eeb0ebad79 |
@ -67,7 +67,7 @@ REFRESH MATERIALIZED VIEW [ CONCURRENTLY ] <replaceable class="parameter">name</
|
|||||||
expression index or include a <literal>WHERE</literal> clause.
|
expression index or include a <literal>WHERE</literal> clause.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
This option may not be used when the materialized view is not already
|
This option can only be used when the materialized view is already
|
||||||
populated.
|
populated.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
|
@ -474,7 +474,7 @@ AlterSequence(ParseState *pstate, AlterSeqStmt *stmt)
|
|||||||
|
|
||||||
seqform = (Form_pg_sequence) GETSTRUCT(seqtuple);
|
seqform = (Form_pg_sequence) GETSTRUCT(seqtuple);
|
||||||
|
|
||||||
/* lock page's buffer and read tuple into new sequence structure */
|
/* lock page buffer and read tuple into new sequence structure */
|
||||||
(void) read_seq_tuple(seqrel, &buf, &datatuple);
|
(void) read_seq_tuple(seqrel, &buf, &datatuple);
|
||||||
|
|
||||||
/* copy the existing sequence data tuple, so it can be modified locally */
|
/* copy the existing sequence data tuple, so it can be modified locally */
|
||||||
@ -678,7 +678,7 @@ nextval_internal(Oid relid, bool check_permissions)
|
|||||||
cycle = pgsform->seqcycle;
|
cycle = pgsform->seqcycle;
|
||||||
ReleaseSysCache(pgstuple);
|
ReleaseSysCache(pgstuple);
|
||||||
|
|
||||||
/* lock page' buffer and read tuple */
|
/* lock page buffer and read tuple */
|
||||||
seq = read_seq_tuple(seqrel, &buf, &seqdatatuple);
|
seq = read_seq_tuple(seqrel, &buf, &seqdatatuple);
|
||||||
page = BufferGetPage(buf);
|
page = BufferGetPage(buf);
|
||||||
|
|
||||||
@ -974,7 +974,7 @@ do_setval(Oid relid, int64 next, bool iscalled)
|
|||||||
*/
|
*/
|
||||||
PreventCommandIfParallelMode("setval()");
|
PreventCommandIfParallelMode("setval()");
|
||||||
|
|
||||||
/* lock page' buffer and read tuple */
|
/* lock page buffer and read tuple */
|
||||||
seq = read_seq_tuple(seqrel, &buf, &seqdatatuple);
|
seq = read_seq_tuple(seqrel, &buf, &seqdatatuple);
|
||||||
|
|
||||||
if ((next < minv) || (next > maxv))
|
if ((next < minv) || (next > maxv))
|
||||||
|
@ -1124,22 +1124,30 @@ copy_table(Relation rel)
|
|||||||
/* Regular table with no row filter */
|
/* Regular table with no row filter */
|
||||||
if (lrel.relkind == RELKIND_RELATION && qual == NIL)
|
if (lrel.relkind == RELKIND_RELATION && qual == NIL)
|
||||||
{
|
{
|
||||||
appendStringInfo(&cmd, "COPY %s (",
|
appendStringInfo(&cmd, "COPY %s",
|
||||||
quote_qualified_identifier(lrel.nspname, lrel.relname));
|
quote_qualified_identifier(lrel.nspname, lrel.relname));
|
||||||
|
|
||||||
/*
|
/* If the table has columns, then specify the columns */
|
||||||
* XXX Do we need to list the columns in all cases? Maybe we're
|
if (lrel.natts)
|
||||||
* replicating all columns?
|
|
||||||
*/
|
|
||||||
for (int i = 0; i < lrel.natts; i++)
|
|
||||||
{
|
{
|
||||||
if (i > 0)
|
appendStringInfoString(&cmd, " (");
|
||||||
appendStringInfoString(&cmd, ", ");
|
|
||||||
|
|
||||||
appendStringInfoString(&cmd, quote_identifier(lrel.attnames[i]));
|
/*
|
||||||
|
* XXX Do we need to list the columns in all cases? Maybe we're
|
||||||
|
* replicating all columns?
|
||||||
|
*/
|
||||||
|
for (int i = 0; i < lrel.natts; i++)
|
||||||
|
{
|
||||||
|
if (i > 0)
|
||||||
|
appendStringInfoString(&cmd, ", ");
|
||||||
|
|
||||||
|
appendStringInfoString(&cmd, quote_identifier(lrel.attnames[i]));
|
||||||
|
}
|
||||||
|
|
||||||
|
appendStringInfoString(&cmd, ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
appendStringInfoString(&cmd, ") TO STDOUT");
|
appendStringInfoString(&cmd, " TO STDOUT");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -57,6 +57,11 @@ $node_publisher->safe_psql('postgres',
|
|||||||
"CREATE INDEX idx_no_replidentity_index ON tab_no_replidentity_index(c1)"
|
"CREATE INDEX idx_no_replidentity_index ON tab_no_replidentity_index(c1)"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
# Replicate the changes without columns
|
||||||
|
$node_publisher->safe_psql('postgres', "CREATE TABLE tab_no_col()");
|
||||||
|
$node_publisher->safe_psql('postgres',
|
||||||
|
"INSERT INTO tab_no_col default VALUES");
|
||||||
|
|
||||||
# Setup structure on subscriber
|
# Setup structure on subscriber
|
||||||
$node_subscriber->safe_psql('postgres', "CREATE TABLE tab_notrep (a int)");
|
$node_subscriber->safe_psql('postgres', "CREATE TABLE tab_notrep (a int)");
|
||||||
$node_subscriber->safe_psql('postgres', "CREATE TABLE tab_ins (a int)");
|
$node_subscriber->safe_psql('postgres', "CREATE TABLE tab_ins (a int)");
|
||||||
@ -87,13 +92,16 @@ $node_subscriber->safe_psql('postgres',
|
|||||||
"CREATE INDEX idx_no_replidentity_index ON tab_no_replidentity_index(c1)"
|
"CREATE INDEX idx_no_replidentity_index ON tab_no_replidentity_index(c1)"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
# replication of the table without columns
|
||||||
|
$node_subscriber->safe_psql('postgres', "CREATE TABLE tab_no_col()");
|
||||||
|
|
||||||
# Setup logical replication
|
# Setup logical replication
|
||||||
my $publisher_connstr = $node_publisher->connstr . ' dbname=postgres';
|
my $publisher_connstr = $node_publisher->connstr . ' dbname=postgres';
|
||||||
$node_publisher->safe_psql('postgres', "CREATE PUBLICATION tap_pub");
|
$node_publisher->safe_psql('postgres', "CREATE PUBLICATION tap_pub");
|
||||||
$node_publisher->safe_psql('postgres',
|
$node_publisher->safe_psql('postgres',
|
||||||
"CREATE PUBLICATION tap_pub_ins_only WITH (publish = insert)");
|
"CREATE PUBLICATION tap_pub_ins_only WITH (publish = insert)");
|
||||||
$node_publisher->safe_psql('postgres',
|
$node_publisher->safe_psql('postgres',
|
||||||
"ALTER PUBLICATION tap_pub ADD TABLE tab_rep, tab_full, tab_full2, tab_mixed, tab_include, tab_nothing, tab_full_pk, tab_no_replidentity_index"
|
"ALTER PUBLICATION tap_pub ADD TABLE tab_rep, tab_full, tab_full2, tab_mixed, tab_include, tab_nothing, tab_full_pk, tab_no_replidentity_index, tab_no_col"
|
||||||
);
|
);
|
||||||
$node_publisher->safe_psql('postgres',
|
$node_publisher->safe_psql('postgres',
|
||||||
"ALTER PUBLICATION tap_pub_ins_only ADD TABLE tab_ins");
|
"ALTER PUBLICATION tap_pub_ins_only ADD TABLE tab_ins");
|
||||||
@ -141,6 +149,9 @@ $node_publisher->safe_psql('postgres', "UPDATE tab_include SET a = -a");
|
|||||||
$node_publisher->safe_psql('postgres',
|
$node_publisher->safe_psql('postgres',
|
||||||
"INSERT INTO tab_no_replidentity_index VALUES(1)");
|
"INSERT INTO tab_no_replidentity_index VALUES(1)");
|
||||||
|
|
||||||
|
$node_publisher->safe_psql('postgres',
|
||||||
|
"INSERT INTO tab_no_col default VALUES");
|
||||||
|
|
||||||
$node_publisher->wait_for_catchup('tap_sub');
|
$node_publisher->wait_for_catchup('tap_sub');
|
||||||
|
|
||||||
$result = $node_subscriber->safe_psql('postgres',
|
$result = $node_subscriber->safe_psql('postgres',
|
||||||
@ -169,6 +180,10 @@ is( $node_subscriber->safe_psql(
|
|||||||
1,
|
1,
|
||||||
"value replicated to subscriber without replica identity index");
|
"value replicated to subscriber without replica identity index");
|
||||||
|
|
||||||
|
$result =
|
||||||
|
$node_subscriber->safe_psql('postgres', "SELECT count(*) FROM tab_no_col");
|
||||||
|
is($result, qq(2), 'check replicated changes for table having no columns');
|
||||||
|
|
||||||
# insert some duplicate rows
|
# insert some duplicate rows
|
||||||
$node_publisher->safe_psql('postgres',
|
$node_publisher->safe_psql('postgres',
|
||||||
"INSERT INTO tab_full SELECT generate_series(1,10)");
|
"INSERT INTO tab_full SELECT generate_series(1,10)");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user