mirror of
				https://github.com/isar/libmdbx.git
				synced 2025-11-04 05:08:57 +08:00 
			
		
		
		
	mdbx: drops old/obsolete API (mdbx_env_copy and mdbx_env_copydf).
This commit is contained in:
		
							
								
								
									
										39
									
								
								mdbx.h
									
									
									
									
									
								
							
							
						
						
									
										39
									
								
								mdbx.h
									
									
									
									
									
								
							@@ -563,37 +563,6 @@ LIBMDBX_API int mdbx_env_open(MDB_env *env, const char *path, unsigned flags,
 | 
			
		||||
LIBMDBX_API int mdbx_env_open_ex(MDB_env *env, const char *path, unsigned flags,
 | 
			
		||||
                                 mode_t mode, int *exclusive);
 | 
			
		||||
 | 
			
		||||
/* Copy an LMDB environment to the specified path.
 | 
			
		||||
 *
 | 
			
		||||
 * This function may be used to make a backup of an existing environment.
 | 
			
		||||
 * No lockfile is created, since it gets recreated at need.
 | 
			
		||||
 * Note: This call can trigger significant file size growth if run in
 | 
			
		||||
 * parallel with write transactions, because it employs a read-only
 | 
			
		||||
 * transaction. See long-lived transactions under caveats_sec.
 | 
			
		||||
 * [in] env An environment handle returned by mdbx_env_create(). It
 | 
			
		||||
 * must have already been opened successfully.
 | 
			
		||||
 * [in] path The directory in which the copy will reside. This
 | 
			
		||||
 * directory must already exist and be writable but must otherwise be
 | 
			
		||||
 * empty.
 | 
			
		||||
 *
 | 
			
		||||
 * Returns A non-zero error value on failure and 0 on success. */
 | 
			
		||||
LIBMDBX_API int mdbx_env_copy(MDB_env *env, const char *path);
 | 
			
		||||
 | 
			
		||||
/* Copy an LMDB environment to the specified file descriptor.
 | 
			
		||||
 *
 | 
			
		||||
 * This function may be used to make a backup of an existing environment.
 | 
			
		||||
 * No lockfile is created, since it gets recreated at need.
 | 
			
		||||
 * Note: This call can trigger significant file size growth if run in
 | 
			
		||||
 * parallel with write transactions, because it employs a read-only
 | 
			
		||||
 * transaction. See long-lived transactions under caveats_sec.
 | 
			
		||||
 * [in] env An environment handle returned by mdbx_env_create(). It
 | 
			
		||||
 * must have already been opened successfully.
 | 
			
		||||
 * [in] fd The filedescriptor to write the copy to. It must
 | 
			
		||||
 * have already been opened for Write access.
 | 
			
		||||
 *
 | 
			
		||||
 * Returns A non-zero error value on failure and 0 on success. */
 | 
			
		||||
LIBMDBX_API int mdbx_env_copyfd(MDB_env *env, mdbx_filehandle_t fd);
 | 
			
		||||
 | 
			
		||||
/* Copy an LMDB environment to the specified path, with options.
 | 
			
		||||
 *
 | 
			
		||||
 * This function may be used to make a backup of an existing environment.
 | 
			
		||||
@@ -617,14 +586,14 @@ LIBMDBX_API int mdbx_env_copyfd(MDB_env *env, mdbx_filehandle_t fd);
 | 
			
		||||
 *leak.
 | 
			
		||||
 *
 | 
			
		||||
 * Returns A non-zero error value on failure and 0 on success. */
 | 
			
		||||
LIBMDBX_API int mdbx_env_copy2(MDB_env *env, const char *path, unsigned flags);
 | 
			
		||||
LIBMDBX_API int mdbx_env_copy(MDB_env *env, const char *path, unsigned flags);
 | 
			
		||||
 | 
			
		||||
/* Copy an LMDB environment to the specified file descriptor,
 | 
			
		||||
 * with options.
 | 
			
		||||
 *
 | 
			
		||||
 * This function may be used to make a backup of an existing environment.
 | 
			
		||||
 * No lockfile is created, since it gets recreated at need. See
 | 
			
		||||
 * mdbx_env_copy2() for further details.
 | 
			
		||||
 * mdbx_env_copy() for further details.
 | 
			
		||||
 * Note: This call can trigger significant file size growth if run in
 | 
			
		||||
 * parallel with write transactions, because it employs a read-only
 | 
			
		||||
 * transaction. See long-lived transactions under caveats_sec.
 | 
			
		||||
@@ -633,10 +602,10 @@ LIBMDBX_API int mdbx_env_copy2(MDB_env *env, const char *path, unsigned flags);
 | 
			
		||||
 * [in] fd The filedescriptor to write the copy to. It must
 | 
			
		||||
 * have already been opened for Write access.
 | 
			
		||||
 * [in] flags Special options for this operation.
 | 
			
		||||
 * See mdbx_env_copy2() for options.
 | 
			
		||||
 * See mdbx_env_copy() for options.
 | 
			
		||||
 *
 | 
			
		||||
 * Returns A non-zero error value on failure and 0 on success. */
 | 
			
		||||
LIBMDBX_API int mdbx_env_copyfd2(MDB_env *env, mdbx_filehandle_t fd,
 | 
			
		||||
LIBMDBX_API int mdbx_env_copy2fd(MDB_env *env, mdbx_filehandle_t fd,
 | 
			
		||||
                                 unsigned flags);
 | 
			
		||||
 | 
			
		||||
/* Return statistics about the LMDB environment.
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										22
									
								
								src/mdbx.c
									
									
									
									
									
								
							
							
						
						
									
										22
									
								
								src/mdbx.c
									
									
									
									
									
								
							@@ -8448,7 +8448,7 @@ done:
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/** Copy environment with compaction. */
 | 
			
		||||
static int __cold mdbx_env_copyfd1(MDB_env *env, mdbx_filehandle_t fd) {
 | 
			
		||||
static int __cold mdbx_env_compact(MDB_env *env, mdbx_filehandle_t fd) {
 | 
			
		||||
  MDB_meta *mm;
 | 
			
		||||
  MDB_page *mp;
 | 
			
		||||
  mdbx_copy my;
 | 
			
		||||
@@ -8548,7 +8548,7 @@ done2:
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/** Copy environment as-is. */
 | 
			
		||||
static int __cold mdbx_env_copyfd0(MDB_env *env, mdbx_filehandle_t fd) {
 | 
			
		||||
static int __cold mdbx_env_copy_asis(MDB_env *env, mdbx_filehandle_t fd) {
 | 
			
		||||
  MDB_txn *txn = NULL;
 | 
			
		||||
  int rc;
 | 
			
		||||
 | 
			
		||||
@@ -8585,19 +8585,15 @@ bailout:
 | 
			
		||||
  return rc;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int __cold mdbx_env_copyfd2(MDB_env *env, mdbx_filehandle_t fd,
 | 
			
		||||
int __cold mdbx_env_copy2fd(MDB_env *env, mdbx_filehandle_t fd,
 | 
			
		||||
                            unsigned flags) {
 | 
			
		||||
  if (flags & MDB_CP_COMPACT)
 | 
			
		||||
    return mdbx_env_copyfd1(env, fd);
 | 
			
		||||
    return mdbx_env_compact(env, fd);
 | 
			
		||||
  else
 | 
			
		||||
    return mdbx_env_copyfd0(env, fd);
 | 
			
		||||
    return mdbx_env_copy_asis(env, fd);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int __cold mdbx_env_copyfd(MDB_env *env, mdbx_filehandle_t fd) {
 | 
			
		||||
  return mdbx_env_copyfd2(env, fd, 0);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int __cold mdbx_env_copy2(MDB_env *env, const char *path, unsigned flags) {
 | 
			
		||||
int __cold mdbx_env_copy(MDB_env *env, const char *path, unsigned flags) {
 | 
			
		||||
  int rc, len;
 | 
			
		||||
  char *lck_pathname;
 | 
			
		||||
  mdbx_filehandle_t newfd = INVALID_HANDLE_VALUE;
 | 
			
		||||
@@ -8627,7 +8623,7 @@ int __cold mdbx_env_copy2(MDB_env *env, const char *path, unsigned flags) {
 | 
			
		||||
        (void)fcntl(newfd, F_SETFL, rc | O_DIRECT);
 | 
			
		||||
#endif
 | 
			
		||||
    }
 | 
			
		||||
    rc = mdbx_env_copyfd2(env, newfd, flags);
 | 
			
		||||
    rc = mdbx_env_copy2fd(env, newfd, flags);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (!(env->me_flags & MDB_NOSUBDIR))
 | 
			
		||||
@@ -8642,10 +8638,6 @@ int __cold mdbx_env_copy2(MDB_env *env, const char *path, unsigned flags) {
 | 
			
		||||
  return rc;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int __cold mdbx_env_copy(MDB_env *env, const char *path) {
 | 
			
		||||
  return mdbx_env_copy2(env, path, 0);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int __cold mdbx_env_set_flags(MDB_env *env, unsigned flags, int onoff) {
 | 
			
		||||
  if (unlikely(flags & ~CHANGEABLE))
 | 
			
		||||
    return MDBX_EINVAL;
 | 
			
		||||
 
 | 
			
		||||
@@ -63,9 +63,9 @@ int main(int argc, char *argv[]) {
 | 
			
		||||
  if (rc == MDB_SUCCESS) {
 | 
			
		||||
    act = "copying";
 | 
			
		||||
    if (argc == 2)
 | 
			
		||||
      rc = mdbx_env_copyfd2(env, STDOUT_FILENO, cpflags);
 | 
			
		||||
      rc = mdbx_env_copy2fd(env, STDOUT_FILENO, cpflags);
 | 
			
		||||
    else
 | 
			
		||||
      rc = mdbx_env_copy2(env, argv[2], cpflags);
 | 
			
		||||
      rc = mdbx_env_copy(env, argv[2], cpflags);
 | 
			
		||||
  }
 | 
			
		||||
  if (rc)
 | 
			
		||||
    fprintf(stderr, "%s: %s failed, error %d (%s)\n", progname, act, rc,
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user