Skip to content

Commit 6a43a2e

Browse files
committed
fix usage of simple_prompt function against PostgreSQL 14 API
1 parent 730c8c6 commit 6a43a2e

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

pgimportdoc.c

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@
2323
#include "pg_getopt.h"
2424
#include "pqexpbuffer.h"
2525

26+
#if PG_VERSION_NUM >= 140000
27+
28+
#include "common/string.h"
29+
30+
#endif
31+
2632
#if PG_VERSION_NUM >= 110000
2733

2834
#include "catalog/pg_type_d.h"
@@ -85,7 +91,11 @@ pgimportdoc(const char *database, const struct _param * param)
8591
int plengths[10];
8692
ExecStatusType status;
8793

88-
#if PG_VERSION_NUM >= 100000
94+
#if PG_VERSION_NUM >= 140000
95+
96+
char *password = NULL;
97+
98+
#elif PG_VERSION_NUM >= 100000
8999

90100
static char password[100];
91101

@@ -101,7 +111,11 @@ pgimportdoc(const char *database, const struct _param * param)
101111
if (param->pg_prompt == TRI_YES && !have_password)
102112
{
103113

104-
#if PG_VERSION_NUM >= 100000
114+
#if PG_VERSION_NUM >= 140000
115+
116+
password = simple_prompt("Password: ", false);
117+
118+
#elif PG_VERSION_NUM >= 100000
105119

106120
simple_prompt("Password: ", password, sizeof(password), false);
107121

@@ -157,7 +171,14 @@ pgimportdoc(const char *database, const struct _param * param)
157171
{
158172
PQfinish(conn);
159173

160-
#if PG_VERSION_NUM >= 100000
174+
#if PG_VERSION_NUM >= 140000
175+
176+
if (password)
177+
free(password);
178+
179+
password = simple_prompt("Password: ", false);
180+
181+
#elif PG_VERSION_NUM >= 100000
161182

162183
simple_prompt("Password: ", password, sizeof(password), false);
163184

0 commit comments

Comments
 (0)