Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Postgres/src/bin/pg_combinebackup/t/   (Postgres Database Version 18.4©)  Datei vom 11.4.2026 mit Größe 1 kB image not shown  

Impressum 006_db_file_copy.pl

  Sprache: Shell
 

# Copyright (c) 2021-2025, PostgreSQL Global Development Group

use strict;
use warnings FATAL => 'all';
use File::Compare;
use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Test::More;

# Can be changed to test the other modes.
my $mode = $ENV{PG_TEST_PG_COMBINEBACKUP_MODE} || '--copy';

note "testing using mode $mode";

# Set up a new database instance.
my $primary = PostgreSQL::Test::Cluster->new('primary');
$primary->init(has_archiving => 1, allows_streaming => 1);
$primary->append_conf('postgresql.conf''summarize_wal = on');
$primary->start;

# Initial setup.
$primary->safe_psql('postgres', <<EOM);
CREATE DATABASE lakh OID = 100000 STRATEGY = FILE_COPY
EOM
$primary->safe_psql('lakh', <<EOM);
CREATE TABLE t1 (a int)
EOM

# Take a full backup.
my $backup1path = $primary->backup_dir . '/backup1';
$primary->command_ok(
 [
  'pg_basebackup',
  '--pgdata' => $backup1path,
  '--no-sync',
  '--checkpoint' => 'fast'
 ],
 "full backup");

# Now make some database changes.
$primary->safe_psql('postgres', <<EOM);
DROP DATABASE lakh;
CREATE DATABASE lakh OID = 100000 STRATEGY = FILE_COPY
EOM

# Take an incremental backup.
my $backup2path = $primary->backup_dir . '/backup2';
$primary->command_ok(
 [
  'pg_basebackup',
  '--pgdata' => $backup2path,
  '--no-sync',
  '--checkpoint' => 'fast',
  '--incremental' => $backup1path . '/backup_manifest'
 ],
 "incremental backup");

# Recover the incremental backup.
my $restore = PostgreSQL::Test::Cluster->new('restore');
$restore->init_from_backup(
 $primary, 'backup2',
 combine_with_prior => ['backup1'],
 combine_mode => $mode);
$restore->start();

# Query the DB.
my $stdout;
my $stderr;
$restore->psql(
 'lakh''SELECT * FROM t1',
 stdout => \$stdout,
 stderr => \$stderr);
is($stdout, '''SELECT * FROM t1: no stdout');
like(
 $stderr,
 qr/relation "t1" does not exist/,
 'SELECT * FROM t1: stderr missing table');

done_testing();

Messung V0.5 in Prozent
C=95 H=99 G=96

¤ Dauer der Verarbeitung: 0.13 Sekunden  (vorverarbeitet am  2026-08-09) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.