You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-07-01 00:25:06 +02:00
Add Db object to encapsulate PostgreSQL queries and commands.
Migrate functionality from the Perl Db module to C. For now this is just enough to implement the WAL switch check. Add the dbGet() helper function to get Db objects easily. Create macros in harnessPq to make writing pq scripts easier by grouping commonly used functions together. Reviewed by Cynthia Shang.
This commit is contained in:
@ -14,6 +14,12 @@ PostgreSQL Interface
|
||||
#include "postgres/version.h"
|
||||
#include "storage/helper.h"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Defines for various Postgres paths and files
|
||||
***********************************************************************************************************************************/
|
||||
STRING_EXTERN(PG_NAME_WAL_STR, PG_NAME_WAL);
|
||||
STRING_EXTERN(PG_NAME_XLOG_STR, PG_NAME_XLOG);
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Define default wal segment size
|
||||
|
||||
@ -35,6 +41,11 @@ something far larger needed but <= the minimum read size on just about any syste
|
||||
***********************************************************************************************************************************/
|
||||
#define PG_WAL_HEADER_SIZE ((unsigned int)(512))
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Name of default PostgreSQL database used for running all queries and commands
|
||||
***********************************************************************************************************************************/
|
||||
STRING_EXTERN(PG_DB_POSTGRES_STR, PG_DB_POSTGRES);
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
PostgreSQL interface definitions
|
||||
|
||||
@ -407,6 +418,19 @@ pgWalFromFile(const String *walFile)
|
||||
FUNCTION_LOG_RETURN(PG_WAL, result);
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Get WAL name (wal/xlog) for a PostgreSQL version
|
||||
***********************************************************************************************************************************/
|
||||
const String *
|
||||
pgWalName(unsigned int pgVersion)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(UINT, pgVersion);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
FUNCTION_TEST_RETURN(pgVersion >= PG_VERSION_WAL_RENAME ? PG_NAME_WAL_STR : PG_NAME_XLOG_STR);
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Create pg_control for testing
|
||||
***********************************************************************************************************************************/
|
||||
|
Reference in New Issue
Block a user