oracle_database_system_management_functions

package
v6.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 10, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

oracle_database_system_management_functions.go Package oracle_database_system_management_functions: helpers for CDB/PDB lifecycle and verification.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Close_pluggable_database_immediate

func Close_pluggable_database_immediate(ctx context.Context, db *sql.DB, pdb_name string, instances_all bool) error

Close_pluggable_database_immediate closes the PDB immediately. If instances_all is true, issues "INSTANCES=ALL" (for RAC).

func Create_open_save_state_pdb_from_seed

func Create_open_save_state_pdb_from_seed(
	ctx context.Context,
	db *sql.DB,
	admin_user string,
	admin_password string,
) (string, string, error)

Create_open_save_state_pdb_from_seed generates a PDB name using date_time_functions.Generate_pdb_name_from_timestamp(), creates the PDB from PDB$SEED, opens it READ WRITE, saves state, verifies, and returns (pdb_name, dest_dir).

func Create_pluggable_database_from_seed

func Create_pluggable_database_from_seed(ctx context.Context, db *sql.DB, pdb_name, admin_user, admin_password string) (string, error)

Create_pluggable_database_from_seed creates a new PDB using FILE_NAME_CONVERT from PDB$SEED. It verifies the PDB$SEED path matches the expected path (root + PDBSEED\) before creating. admin_user/admin_password are used for the PDB admin account. Returns the computed destination directory (root\pdb_name\).

func Discard_pluggable_database_state

func Discard_pluggable_database_state(ctx context.Context, db *sql.DB, pdb_name string) error

Discard_pluggable_database_state removes any saved state for the PDB, preventing auto-open on next CDB restart.

func Drop_pluggable_database_including_datafiles

func Drop_pluggable_database_including_datafiles(ctx context.Context, db *sql.DB, pdb_name string) error

Drop_pluggable_database_including_datafiles drops the PDB and removes its datafiles. The PDB must be closed on all instances (in RAC) before this succeeds.

func Ensure_connected_to_cdb_root

func Ensure_connected_to_cdb_root(ctx context.Context, db *sql.DB) error

Ensure_connected_to_cdb_root returns error unless current container is CDB$ROOT.

func Get_pdb_status

func Get_pdb_status(ctx context.Context, db *sql.DB, pdb_name string) (string, error)

Get_pdb_status returns the OPEN_MODE from V$PDBS for the given PDB name.

func Get_pdbseed_datafile_directory

func Get_pdbseed_datafile_directory(ctx context.Context, db *sql.DB) (string, error)

Get_pdbseed_datafile_directory returns the directory where PDB$SEED's SYSTEM01.DBF resides, normalized to Windows backslash with a trailing backslash.

func Get_root_datafile_directory

func Get_root_datafile_directory(ctx context.Context, db *sql.DB) (string, error)

Get_root_datafile_directory returns the directory where CDB$ROOT's SYSTEM01.DBF resides, normalized to Windows backslash with a trailing backslash.

func Get_saved_state_info

func Get_saved_state_info(ctx context.Context, db *sql.DB, pdb_name string) (string, string, error)

Get_saved_state_info returns (STATE, RESTRICTED) from DBA_PDB_SAVED_STATES for the PDB (by CON_NAME). If the row is not present, it returns ("","") and nil error.

func Get_user_sessions

func Get_user_sessions(ctx context.Context, db *sql.DB, pdb_name string) ([]user_session, error)

Get_user_sessions returns all USER sessions attached to the given PDB. Note: the returned struct and its fields are unexported (snake_case). If you want callers in other packages to access fields directly, we can provide an exported DTO or accessor helpers.

func Kill_user_sessions_in_pdb

func Kill_user_sessions_in_pdb(ctx context.Context, db *sql.DB, pdb_name string) error

Kill_user_sessions_in_pdb terminates all USER sessions attached to the given PDB (single pass).

func Kill_user_sessions_in_pdb_until_gone

func Kill_user_sessions_in_pdb_until_gone(
	ctx context.Context,
	db *sql.DB,
	pdb_name string,
	max_attempts int,
	wait_between_attempts time.Duration,
) error

Kill_user_sessions_in_pdb_until_gone keeps killing USER sessions in the PDB until none remain or until max_attempts (default: 100) is reached. It rechecks with Get_user_sessions between attempts. wait_between_attempts controls the sleep duration between attempts.

func Open_pluggable_database_read_write

func Open_pluggable_database_read_write(ctx context.Context, db *sql.DB, pdb_name string) error

Open_pluggable_database_read_write opens the given PDB READ WRITE.

func Save_pluggable_database_state

func Save_pluggable_database_state(ctx context.Context, db *sql.DB, pdb_name string) error

Save_pluggable_database_state saves the auto-open state for the given PDB.

func Teardown_drop_pdb

func Teardown_drop_pdb(
	ctx context.Context,
	db *sql.DB,
	pdb_name string,
	instances_all bool,
	kill_sessions bool,
) error

Teardown_drop_pdb closes, discards state, and drops a PDB INCLUDING DATAFILES. If kill_sessions is true, it will attempt to terminate USER sessions in that PDB first (retrying until none remain, up to 100 attempts, with 300ms between attempts). If instances_all is true, CLOSE IMMEDIATE will be issued with INSTANCES=ALL (for RAC). The function also verifies the drop via DBA_PDBS and inspects saved state after DISCARD STATE.

func Verify_pdbseed_directory_matches_expected

func Verify_pdbseed_directory_matches_expected(ctx context.Context, db *sql.DB) error

Verify_pdbseed_directory_matches_expected checks that root\PDBSEED\ equals actual PDB$SEED location.

func Verify_pluggable_database_dropped

func Verify_pluggable_database_dropped(ctx context.Context, db *sql.DB, pdb_name string) (bool, error)

Verify_pluggable_database_dropped returns true if DBA_PDBS no longer has the PDB.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL