]> git.proxmox.com Git - ceph.git/blob - ceph/src/rgw/driver/dbstore/sqlite/connection.cc
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / rgw / driver / dbstore / sqlite / connection.cc
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab ft=cpp
3
4 /*
5 * Ceph - scalable distributed file system
6 *
7 * Copyright (C) 2022 Red Hat, Inc.
8 *
9 * This is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License version 2.1, as published by the Free Software
12 * Foundation. See file COPYING.
13 *
14 */
15
16 #include "common/dout.h"
17 #include "connection.h"
18 #include "error.h"
19
20 namespace rgw::dbstore::sqlite {
21
22 db_ptr open_database(const char* filename, int flags)
23 {
24 sqlite3* db = nullptr;
25 const int result = ::sqlite3_open_v2(filename, &db, flags, nullptr);
26 if (result != SQLITE_OK) {
27 throw std::system_error(result, sqlite::error_category());
28 }
29 // request extended result codes
30 (void) ::sqlite3_extended_result_codes(db, 1);
31 return db_ptr{db};
32 }
33
34 } // namespace rgw::dbstore::sqlite