mirror of
https://github.com/postgres/postgres.git
synced 2025-07-07 00:36:50 +03:00
Change TRUE/FALSE to true/false
The lower case spellings are C and C++ standard and are used in most parts of the PostgreSQL sources. The upper case spellings are only used in some files/modules. So standardize on the standard spellings. The APIs for ICU, Perl, and Windows define their own TRUE and FALSE, so those are left as is when using those APIs. In code comments, we use the lower-case spelling for the C concepts and keep the upper-case spelling for the SQL concepts. Reviewed-by: Michael Paquier <michael.paquier@gmail.com>
This commit is contained in:
@ -225,13 +225,13 @@ ECPGtrans(int lineno, const char *connection_name, const char *transaction)
|
||||
{
|
||||
res = PQexec(con->connection, "begin transaction");
|
||||
if (!ecpg_check_PQresult(res, lineno, con->connection, ECPG_COMPAT_PGSQL))
|
||||
return FALSE;
|
||||
return false;
|
||||
PQclear(res);
|
||||
}
|
||||
|
||||
res = PQexec(con->connection, transaction);
|
||||
if (!ecpg_check_PQresult(res, lineno, con->connection, ECPG_COMPAT_PGSQL))
|
||||
return FALSE;
|
||||
return false;
|
||||
PQclear(res);
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ PGTYPESdate_from_asc(char *str, char **endptr)
|
||||
char *realptr;
|
||||
char **ptr = (endptr != NULL) ? endptr : &realptr;
|
||||
|
||||
bool EuroDates = FALSE;
|
||||
bool EuroDates = false;
|
||||
|
||||
errno = 0;
|
||||
if (strlen(str) > MAXDATELEN)
|
||||
@ -105,7 +105,7 @@ PGTYPESdate_to_asc(date dDate)
|
||||
*tm = &tt;
|
||||
char buf[MAXDATELEN + 1];
|
||||
int DateStyle = 1;
|
||||
bool EuroDates = FALSE;
|
||||
bool EuroDates = false;
|
||||
|
||||
j2date(dDate + date2j(2000, 1, 1), &(tm->tm_year), &(tm->tm_mon), &(tm->tm_mday));
|
||||
EncodeDateOnly(tm, DateStyle, buf, EuroDates);
|
||||
|
@ -1144,7 +1144,7 @@ DecodeNumberField(int len, char *str, int fmask,
|
||||
tm->tm_mon = atoi(str + 2);
|
||||
*(str + 2) = '\0';
|
||||
tm->tm_year = atoi(str + 0);
|
||||
*is2digits = TRUE;
|
||||
*is2digits = true;
|
||||
|
||||
return DTK_DATE;
|
||||
}
|
||||
@ -1156,7 +1156,7 @@ DecodeNumberField(int len, char *str, int fmask,
|
||||
*(str + 2) = '\0';
|
||||
tm->tm_mon = 1;
|
||||
tm->tm_year = atoi(str + 0);
|
||||
*is2digits = TRUE;
|
||||
*is2digits = true;
|
||||
|
||||
return DTK_DATE;
|
||||
}
|
||||
@ -1314,8 +1314,8 @@ DecodeDate(char *str, int fmask, int *tmask, struct tm *tm, bool EuroDates)
|
||||
int nf = 0;
|
||||
int i,
|
||||
len;
|
||||
bool bc = FALSE;
|
||||
bool is2digits = FALSE;
|
||||
bool bc = false;
|
||||
bool is2digits = false;
|
||||
int type,
|
||||
val,
|
||||
dmask = 0;
|
||||
@ -1792,9 +1792,9 @@ DecodeDateTime(char **field, int *ftype, int nf,
|
||||
int i;
|
||||
int val;
|
||||
int mer = HR24;
|
||||
bool haveTextMonth = FALSE;
|
||||
bool is2digits = FALSE;
|
||||
bool bc = FALSE;
|
||||
bool haveTextMonth = false;
|
||||
bool is2digits = false;
|
||||
bool bc = false;
|
||||
int t = 0;
|
||||
int *tzp = &t;
|
||||
|
||||
@ -2200,7 +2200,7 @@ DecodeDateTime(char **field, int *ftype, int nf,
|
||||
tm->tm_mday = tm->tm_mon;
|
||||
tmask = DTK_M(DAY);
|
||||
}
|
||||
haveTextMonth = TRUE;
|
||||
haveTextMonth = true;
|
||||
tm->tm_mon = val;
|
||||
break;
|
||||
|
||||
|
@ -338,7 +338,7 @@ DecodeInterval(char **field, int *ftype, int nf, /* int range, */
|
||||
{
|
||||
int IntervalStyle = INTSTYLE_POSTGRES_VERBOSE;
|
||||
int range = INTERVAL_FULL_RANGE;
|
||||
bool is_before = FALSE;
|
||||
bool is_before = false;
|
||||
char *cp;
|
||||
int fmask = 0,
|
||||
tmask,
|
||||
@ -583,7 +583,7 @@ DecodeInterval(char **field, int *ftype, int nf, /* int range, */
|
||||
break;
|
||||
|
||||
case AGO:
|
||||
is_before = TRUE;
|
||||
is_before = true;
|
||||
type = val;
|
||||
break;
|
||||
|
||||
@ -705,7 +705,7 @@ AddVerboseIntPart(char *cp, int value, const char *units,
|
||||
else if (*is_before)
|
||||
value = -value;
|
||||
sprintf(cp, " %d %s%s", value, units, (value == 1) ? "" : "s");
|
||||
*is_zero = FALSE;
|
||||
*is_zero = false;
|
||||
return cp + strlen(cp);
|
||||
}
|
||||
|
||||
@ -728,7 +728,7 @@ AddPostgresIntPart(char *cp, int value, const char *units,
|
||||
* tad bizarre but it's how it worked before...
|
||||
*/
|
||||
*is_before = (value < 0);
|
||||
*is_zero = FALSE;
|
||||
*is_zero = false;
|
||||
return cp + strlen(cp);
|
||||
}
|
||||
|
||||
@ -779,8 +779,8 @@ EncodeInterval(struct /* pg_ */ tm *tm, fsec_t fsec, int style, char *str)
|
||||
int hour = tm->tm_hour;
|
||||
int min = tm->tm_min;
|
||||
int sec = tm->tm_sec;
|
||||
bool is_before = FALSE;
|
||||
bool is_zero = TRUE;
|
||||
bool is_before = false;
|
||||
bool is_zero = true;
|
||||
|
||||
/*
|
||||
* The sign of year and month are guaranteed to match, since they are
|
||||
@ -926,7 +926,7 @@ EncodeInterval(struct /* pg_ */ tm *tm, fsec_t fsec, int style, char *str)
|
||||
if (sec < 0 || (sec == 0 && fsec < 0))
|
||||
{
|
||||
if (is_zero)
|
||||
is_before = TRUE;
|
||||
is_before = true;
|
||||
else if (!is_before)
|
||||
*cp++ = '-';
|
||||
}
|
||||
@ -936,7 +936,7 @@ EncodeInterval(struct /* pg_ */ tm *tm, fsec_t fsec, int style, char *str)
|
||||
cp += strlen(cp);
|
||||
sprintf(cp, " sec%s",
|
||||
(abs(sec) != 1 || fsec != 0) ? "s" : "");
|
||||
is_zero = FALSE;
|
||||
is_zero = false;
|
||||
}
|
||||
/* identically zero? then put in a unitless zero... */
|
||||
if (is_zero)
|
||||
|
@ -162,7 +162,7 @@ PGTYPESdecimal_new(void)
|
||||
static int
|
||||
set_var_from_str(char *str, char **ptr, numeric *dest)
|
||||
{
|
||||
bool have_dp = FALSE;
|
||||
bool have_dp = false;
|
||||
int i = 0;
|
||||
|
||||
errno = 0;
|
||||
@ -214,7 +214,7 @@ set_var_from_str(char *str, char **ptr, numeric *dest)
|
||||
|
||||
if (*(*ptr) == '.')
|
||||
{
|
||||
have_dp = TRUE;
|
||||
have_dp = true;
|
||||
(*ptr)++;
|
||||
}
|
||||
|
||||
@ -241,7 +241,7 @@ set_var_from_str(char *str, char **ptr, numeric *dest)
|
||||
errno = PGTYPES_NUM_BAD_NUMERIC;
|
||||
return -1;
|
||||
}
|
||||
have_dp = TRUE;
|
||||
have_dp = true;
|
||||
(*ptr)++;
|
||||
}
|
||||
else
|
||||
|
@ -989,12 +989,12 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
|
||||
return S_ANYTHING;
|
||||
}
|
||||
}
|
||||
<C,xskip>{exec_sql}{ifdef}{space}* { ifcond = TRUE; BEGIN(xcond); }
|
||||
<C,xskip>{exec_sql}{ifdef}{space}* { ifcond = true; BEGIN(xcond); }
|
||||
<C,xskip>{informix_special}{ifdef}{space}* {
|
||||
/* are we simulating Informix? */
|
||||
if (INFORMIX_MODE)
|
||||
{
|
||||
ifcond = TRUE;
|
||||
ifcond = true;
|
||||
BEGIN(xcond);
|
||||
}
|
||||
else
|
||||
@ -1003,12 +1003,12 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
|
||||
return S_ANYTHING;
|
||||
}
|
||||
}
|
||||
<C,xskip>{exec_sql}{ifndef}{space}* { ifcond = FALSE; BEGIN(xcond); }
|
||||
<C,xskip>{exec_sql}{ifndef}{space}* { ifcond = false; BEGIN(xcond); }
|
||||
<C,xskip>{informix_special}{ifndef}{space}* {
|
||||
/* are we simulating Informix? */
|
||||
if (INFORMIX_MODE)
|
||||
{
|
||||
ifcond = FALSE;
|
||||
ifcond = false;
|
||||
BEGIN(xcond);
|
||||
}
|
||||
else
|
||||
@ -1026,7 +1026,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
|
||||
else
|
||||
preproc_tos--;
|
||||
|
||||
ifcond = TRUE; BEGIN(xcond);
|
||||
ifcond = true; BEGIN(xcond);
|
||||
}
|
||||
<C,xskip>{informix_special}{elif}{space}* {
|
||||
/* are we simulating Informix? */
|
||||
@ -1039,7 +1039,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
|
||||
else
|
||||
preproc_tos--;
|
||||
|
||||
ifcond = TRUE;
|
||||
ifcond = true;
|
||||
BEGIN(xcond);
|
||||
}
|
||||
else
|
||||
@ -1054,7 +1054,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
|
||||
mmfatal(PARSE_ERROR, "more than one EXEC SQL ELSE");
|
||||
else
|
||||
{
|
||||
stacked_if_value[preproc_tos].else_branch = TRUE;
|
||||
stacked_if_value[preproc_tos].else_branch = true;
|
||||
stacked_if_value[preproc_tos].condition =
|
||||
(stacked_if_value[preproc_tos-1].condition &&
|
||||
!stacked_if_value[preproc_tos].condition);
|
||||
@ -1073,7 +1073,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
|
||||
mmfatal(PARSE_ERROR, "more than one EXEC SQL ELSE");
|
||||
else
|
||||
{
|
||||
stacked_if_value[preproc_tos].else_branch = TRUE;
|
||||
stacked_if_value[preproc_tos].else_branch = true;
|
||||
stacked_if_value[preproc_tos].condition =
|
||||
(stacked_if_value[preproc_tos-1].condition &&
|
||||
!stacked_if_value[preproc_tos].condition);
|
||||
@ -1147,7 +1147,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
|
||||
defptr = defptr->next);
|
||||
|
||||
preproc_tos++;
|
||||
stacked_if_value[preproc_tos].else_branch = FALSE;
|
||||
stacked_if_value[preproc_tos].else_branch = false;
|
||||
stacked_if_value[preproc_tos].condition =
|
||||
(defptr ? ifcond : !ifcond) && stacked_if_value[preproc_tos-1].condition;
|
||||
}
|
||||
@ -1265,9 +1265,9 @@ lex_init(void)
|
||||
|
||||
preproc_tos = 0;
|
||||
yylineno = 1;
|
||||
ifcond = TRUE;
|
||||
ifcond = true;
|
||||
stacked_if_value[preproc_tos].condition = ifcond;
|
||||
stacked_if_value[preproc_tos].else_branch = FALSE;
|
||||
stacked_if_value[preproc_tos].else_branch = false;
|
||||
|
||||
/* initialize literal buffer to a reasonable but expansible size */
|
||||
if (literalbuf == NULL)
|
||||
@ -1412,7 +1412,7 @@ parse_include(void)
|
||||
}
|
||||
|
||||
/*
|
||||
* ecpg_isspace() --- return TRUE if flex scanner considers char whitespace
|
||||
* ecpg_isspace() --- return true if flex scanner considers char whitespace
|
||||
*/
|
||||
static bool
|
||||
ecpg_isspace(char ch)
|
||||
|
@ -3586,7 +3586,7 @@ closePGconn(PGconn *conn)
|
||||
* Don't call PQsetnonblocking() because it will fail if it's unable to
|
||||
* flush the connection.
|
||||
*/
|
||||
conn->nonblocking = FALSE;
|
||||
conn->nonblocking = false;
|
||||
|
||||
/*
|
||||
* Close the connection, reset all transient state, flush I/O buffers.
|
||||
@ -3781,8 +3781,8 @@ PQfreeCancel(PGcancel *cancel)
|
||||
* PQcancel and PQrequestCancel: attempt to request cancellation of the
|
||||
* current operation.
|
||||
*
|
||||
* The return value is TRUE if the cancel request was successfully
|
||||
* dispatched, FALSE if not (in which case an error message is available).
|
||||
* The return value is true if the cancel request was successfully
|
||||
* dispatched, false if not (in which case an error message is available).
|
||||
* Note: successful dispatch is no guarantee that there will be any effect at
|
||||
* the backend. The application must read the operation result as usual.
|
||||
*
|
||||
@ -3871,7 +3871,7 @@ retry5:
|
||||
/* All done */
|
||||
closesocket(tmpsock);
|
||||
SOCK_ERRNO_SET(save_errno);
|
||||
return TRUE;
|
||||
return true;
|
||||
|
||||
cancel_errReturn:
|
||||
|
||||
@ -3889,13 +3889,13 @@ cancel_errReturn:
|
||||
if (tmpsock != PGINVALID_SOCKET)
|
||||
closesocket(tmpsock);
|
||||
SOCK_ERRNO_SET(save_errno);
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* PQcancel: request query cancel
|
||||
*
|
||||
* Returns TRUE if able to send the cancel request, FALSE if not.
|
||||
* Returns true if able to send the cancel request, false if not.
|
||||
*
|
||||
* On failure, an error message is stored in *errbuf, which must be of size
|
||||
* errbufsize (recommended size is 256 bytes). *errbuf is not changed on
|
||||
@ -3907,7 +3907,7 @@ PQcancel(PGcancel *cancel, char *errbuf, int errbufsize)
|
||||
if (!cancel)
|
||||
{
|
||||
strlcpy(errbuf, "PQcancel() -- no cancel object supplied", errbufsize);
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
return internal_cancel(&cancel->raddr, cancel->be_pid, cancel->be_key,
|
||||
@ -3917,7 +3917,7 @@ PQcancel(PGcancel *cancel, char *errbuf, int errbufsize)
|
||||
/*
|
||||
* PQrequestCancel: old, not thread-safe function for requesting query cancel
|
||||
*
|
||||
* Returns TRUE if able to send the cancel request, FALSE if not.
|
||||
* Returns true if able to send the cancel request, false if not.
|
||||
*
|
||||
* On failure, the error message is saved in conn->errorMessage; this means
|
||||
* that this can't be used when there might be other active operations on
|
||||
@ -3933,7 +3933,7 @@ PQrequestCancel(PGconn *conn)
|
||||
|
||||
/* Check we have an open connection */
|
||||
if (!conn)
|
||||
return FALSE;
|
||||
return false;
|
||||
|
||||
if (conn->sock == PGINVALID_SOCKET)
|
||||
{
|
||||
@ -3942,7 +3942,7 @@ PQrequestCancel(PGconn *conn)
|
||||
conn->errorMessage.maxlen);
|
||||
conn->errorMessage.len = strlen(conn->errorMessage.data);
|
||||
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
r = internal_cancel(&conn->raddr, conn->be_pid, conn->be_key,
|
||||
@ -4781,7 +4781,7 @@ conninfo_init(PQExpBuffer errorMessage)
|
||||
* Returns a malloc'd PQconninfoOption array, if parsing is successful.
|
||||
* Otherwise, NULL is returned and an error message is left in errorMessage.
|
||||
*
|
||||
* If use_defaults is TRUE, default values are filled in (from a service file,
|
||||
* If use_defaults is true, default values are filled in (from a service file,
|
||||
* environment variables, etc).
|
||||
*/
|
||||
static PQconninfoOption *
|
||||
@ -5004,7 +5004,7 @@ conninfo_parse(const char *conninfo, PQExpBuffer errorMessage,
|
||||
* If not successful, NULL is returned and an error message is
|
||||
* left in errorMessage.
|
||||
* Defaults are supplied (from a service file, environment variables, etc)
|
||||
* for unspecified options, but only if use_defaults is TRUE.
|
||||
* for unspecified options, but only if use_defaults is true.
|
||||
*
|
||||
* If expand_dbname is non-zero, and the value passed for the first occurrence
|
||||
* of "dbname" keyword is a connection string (as indicated by
|
||||
@ -5175,7 +5175,7 @@ conninfo_array_parse(const char *const *keywords, const char *const *values,
|
||||
*
|
||||
* Defaults are obtained from a service file, environment variables, etc.
|
||||
*
|
||||
* Returns TRUE if successful, otherwise FALSE; errorMessage, if supplied,
|
||||
* Returns true if successful, otherwise false; errorMessage, if supplied,
|
||||
* is filled in upon failure. Note that failure to locate a default value
|
||||
* is not an error condition here --- we just leave the option's value as
|
||||
* NULL.
|
||||
@ -5826,7 +5826,7 @@ conninfo_getval(PQconninfoOption *connOptions,
|
||||
*
|
||||
* If not successful, returns NULL and fills errorMessage accordingly.
|
||||
* However, if the reason of failure is an invalid keyword being passed and
|
||||
* ignoreMissing is TRUE, errorMessage will be left untouched.
|
||||
* ignoreMissing is true, errorMessage will be left untouched.
|
||||
*/
|
||||
static PQconninfoOption *
|
||||
conninfo_storeval(PQconninfoOption *connOptions,
|
||||
|
@ -231,17 +231,17 @@ PQsetResultAttrs(PGresult *res, int numAttributes, PGresAttDesc *attDescs)
|
||||
|
||||
/* If attrs already exist, they cannot be overwritten. */
|
||||
if (!res || res->numAttributes > 0)
|
||||
return FALSE;
|
||||
return false;
|
||||
|
||||
/* ignore no-op request */
|
||||
if (numAttributes <= 0 || !attDescs)
|
||||
return TRUE;
|
||||
return true;
|
||||
|
||||
res->attDescs = (PGresAttDesc *)
|
||||
PQresultAlloc(res, numAttributes * sizeof(PGresAttDesc));
|
||||
|
||||
if (!res->attDescs)
|
||||
return FALSE;
|
||||
return false;
|
||||
|
||||
res->numAttributes = numAttributes;
|
||||
memcpy(res->attDescs, attDescs, numAttributes * sizeof(PGresAttDesc));
|
||||
@ -256,13 +256,13 @@ PQsetResultAttrs(PGresult *res, int numAttributes, PGresAttDesc *attDescs)
|
||||
res->attDescs[i].name = res->null_field;
|
||||
|
||||
if (!res->attDescs[i].name)
|
||||
return FALSE;
|
||||
return false;
|
||||
|
||||
if (res->attDescs[i].format == 0)
|
||||
res->binary = 0;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -368,7 +368,7 @@ PQcopyResult(const PGresult *src, int flags)
|
||||
PQclear(dest);
|
||||
return NULL;
|
||||
}
|
||||
dest->events[i].resultInitialized = TRUE;
|
||||
dest->events[i].resultInitialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -398,7 +398,7 @@ dupEvents(PGEvent *events, int count)
|
||||
newEvents[i].proc = events[i].proc;
|
||||
newEvents[i].passThrough = events[i].passThrough;
|
||||
newEvents[i].data = NULL;
|
||||
newEvents[i].resultInitialized = FALSE;
|
||||
newEvents[i].resultInitialized = false;
|
||||
newEvents[i].name = strdup(events[i].name);
|
||||
if (!newEvents[i].name)
|
||||
{
|
||||
@ -428,7 +428,7 @@ PQsetvalue(PGresult *res, int tup_num, int field_num, char *value, int len)
|
||||
|
||||
/* Note that this check also protects us against null "res" */
|
||||
if (!check_field_number(res, field_num))
|
||||
return FALSE;
|
||||
return false;
|
||||
|
||||
/* Invalid tup_num, must be <= ntups */
|
||||
if (tup_num < 0 || tup_num > res->ntups)
|
||||
@ -436,7 +436,7 @@ PQsetvalue(PGresult *res, int tup_num, int field_num, char *value, int len)
|
||||
pqInternalNotice(&res->noticeHooks,
|
||||
"row number %d is out of range 0..%d",
|
||||
tup_num, res->ntups);
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* need to allocate a new tuple? */
|
||||
@ -447,7 +447,7 @@ PQsetvalue(PGresult *res, int tup_num, int field_num, char *value, int len)
|
||||
|
||||
tup = (PGresAttValue *)
|
||||
pqResultAlloc(res, res->numAttributes * sizeof(PGresAttValue),
|
||||
TRUE);
|
||||
true);
|
||||
|
||||
if (!tup)
|
||||
goto fail;
|
||||
@ -479,7 +479,7 @@ PQsetvalue(PGresult *res, int tup_num, int field_num, char *value, int len)
|
||||
}
|
||||
else
|
||||
{
|
||||
attval->value = (char *) pqResultAlloc(res, len + 1, TRUE);
|
||||
attval->value = (char *) pqResultAlloc(res, len + 1, true);
|
||||
if (!attval->value)
|
||||
goto fail;
|
||||
attval->len = len;
|
||||
@ -487,7 +487,7 @@ PQsetvalue(PGresult *res, int tup_num, int field_num, char *value, int len)
|
||||
attval->value[len] = '\0';
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
return true;
|
||||
|
||||
/*
|
||||
* Report failure via pqInternalNotice. If preceding code didn't provide
|
||||
@ -498,7 +498,7 @@ fail:
|
||||
errmsg = libpq_gettext("out of memory");
|
||||
pqInternalNotice(&res->noticeHooks, "%s", errmsg);
|
||||
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -510,7 +510,7 @@ fail:
|
||||
void *
|
||||
PQresultAlloc(PGresult *res, size_t nBytes)
|
||||
{
|
||||
return pqResultAlloc(res, nBytes, TRUE);
|
||||
return pqResultAlloc(res, nBytes, true);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -622,7 +622,7 @@ pqResultAlloc(PGresult *res, size_t nBytes, bool isBinary)
|
||||
char *
|
||||
pqResultStrdup(PGresult *res, const char *str)
|
||||
{
|
||||
char *space = (char *) pqResultAlloc(res, strlen(str) + 1, FALSE);
|
||||
char *space = (char *) pqResultAlloc(res, strlen(str) + 1, false);
|
||||
|
||||
if (space)
|
||||
strcpy(space, str);
|
||||
@ -852,7 +852,7 @@ pqInternalNotice(const PGNoticeHooks *hooks, const char *fmt,...)
|
||||
* Result text is always just the primary message + newline. If we can't
|
||||
* allocate it, don't bother invoking the receiver.
|
||||
*/
|
||||
res->errMsg = (char *) pqResultAlloc(res, strlen(msgBuf) + 2, FALSE);
|
||||
res->errMsg = (char *) pqResultAlloc(res, strlen(msgBuf) + 2, false);
|
||||
if (res->errMsg)
|
||||
{
|
||||
sprintf(res->errMsg, "%s\n", msgBuf);
|
||||
@ -868,7 +868,7 @@ pqInternalNotice(const PGNoticeHooks *hooks, const char *fmt,...)
|
||||
/*
|
||||
* pqAddTuple
|
||||
* add a row pointer to the PGresult structure, growing it if necessary
|
||||
* Returns TRUE if OK, FALSE if an error prevented adding the row
|
||||
* Returns true if OK, false if an error prevented adding the row
|
||||
*
|
||||
* On error, *errmsgp can be set to an error string to be returned.
|
||||
* If it is left NULL, the error is presumed to be "out of memory".
|
||||
@ -903,7 +903,7 @@ pqAddTuple(PGresult *res, PGresAttValue *tup, const char **errmsgp)
|
||||
else
|
||||
{
|
||||
*errmsgp = libpq_gettext("PGresult cannot support more than INT_MAX tuples");
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -915,7 +915,7 @@ pqAddTuple(PGresult *res, PGresAttValue *tup, const char **errmsgp)
|
||||
if (newSize > SIZE_MAX / sizeof(PGresAttValue *))
|
||||
{
|
||||
*errmsgp = libpq_gettext("size_t overflow");
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -926,13 +926,13 @@ pqAddTuple(PGresult *res, PGresAttValue *tup, const char **errmsgp)
|
||||
newTuples = (PGresAttValue **)
|
||||
realloc(res->tuples, newSize * sizeof(PGresAttValue *));
|
||||
if (!newTuples)
|
||||
return FALSE; /* malloc or realloc failed */
|
||||
return false; /* malloc or realloc failed */
|
||||
res->tupArrSize = newSize;
|
||||
res->tuples = newTuples;
|
||||
}
|
||||
res->tuples[res->ntups] = tup;
|
||||
res->ntups++;
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -947,7 +947,7 @@ pqSaveMessageField(PGresult *res, char code, const char *value)
|
||||
pqResultAlloc(res,
|
||||
offsetof(PGMessageField, contents) +
|
||||
strlen(value) + 1,
|
||||
TRUE);
|
||||
true);
|
||||
if (!pfield)
|
||||
return; /* out of memory? */
|
||||
pfield->code = code;
|
||||
@ -1111,7 +1111,7 @@ pqRowProcessor(PGconn *conn, const char **errmsgp)
|
||||
* memory for gettext() to do anything.
|
||||
*/
|
||||
tup = (PGresAttValue *)
|
||||
pqResultAlloc(res, nfields * sizeof(PGresAttValue), TRUE);
|
||||
pqResultAlloc(res, nfields * sizeof(PGresAttValue), true);
|
||||
if (tup == NULL)
|
||||
goto fail;
|
||||
|
||||
@ -1725,14 +1725,14 @@ parseInput(PGconn *conn)
|
||||
|
||||
/*
|
||||
* PQisBusy
|
||||
* Return TRUE if PQgetResult would block waiting for input.
|
||||
* Return true if PQgetResult would block waiting for input.
|
||||
*/
|
||||
|
||||
int
|
||||
PQisBusy(PGconn *conn)
|
||||
{
|
||||
if (!conn)
|
||||
return FALSE;
|
||||
return false;
|
||||
|
||||
/* Parse any available data, if our state permits. */
|
||||
parseInput(conn);
|
||||
@ -1771,7 +1771,7 @@ PQgetResult(PGconn *conn)
|
||||
*/
|
||||
while ((flushResult = pqFlush(conn)) > 0)
|
||||
{
|
||||
if (pqWait(FALSE, TRUE, conn))
|
||||
if (pqWait(false, true, conn))
|
||||
{
|
||||
flushResult = -1;
|
||||
break;
|
||||
@ -1780,7 +1780,7 @@ PQgetResult(PGconn *conn)
|
||||
|
||||
/* Wait for some more data, and load it. */
|
||||
if (flushResult ||
|
||||
pqWait(TRUE, FALSE, conn) ||
|
||||
pqWait(true, false, conn) ||
|
||||
pqReadData(conn) < 0)
|
||||
{
|
||||
/*
|
||||
@ -1844,7 +1844,7 @@ PQgetResult(PGconn *conn)
|
||||
res->resultStatus = PGRES_FATAL_ERROR;
|
||||
break;
|
||||
}
|
||||
res->events[i].resultInitialized = TRUE;
|
||||
res->events[i].resultInitialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2746,22 +2746,22 @@ PQbinaryTuples(const PGresult *res)
|
||||
|
||||
/*
|
||||
* Helper routines to range-check field numbers and tuple numbers.
|
||||
* Return TRUE if OK, FALSE if not
|
||||
* Return true if OK, false if not
|
||||
*/
|
||||
|
||||
static int
|
||||
check_field_number(const PGresult *res, int field_num)
|
||||
{
|
||||
if (!res)
|
||||
return FALSE; /* no way to display error message... */
|
||||
return false; /* no way to display error message... */
|
||||
if (field_num < 0 || field_num >= res->numAttributes)
|
||||
{
|
||||
pqInternalNotice(&res->noticeHooks,
|
||||
"column number %d is out of range 0..%d",
|
||||
field_num, res->numAttributes - 1);
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int
|
||||
@ -2769,38 +2769,38 @@ check_tuple_field_number(const PGresult *res,
|
||||
int tup_num, int field_num)
|
||||
{
|
||||
if (!res)
|
||||
return FALSE; /* no way to display error message... */
|
||||
return false; /* no way to display error message... */
|
||||
if (tup_num < 0 || tup_num >= res->ntups)
|
||||
{
|
||||
pqInternalNotice(&res->noticeHooks,
|
||||
"row number %d is out of range 0..%d",
|
||||
tup_num, res->ntups - 1);
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
if (field_num < 0 || field_num >= res->numAttributes)
|
||||
{
|
||||
pqInternalNotice(&res->noticeHooks,
|
||||
"column number %d is out of range 0..%d",
|
||||
field_num, res->numAttributes - 1);
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int
|
||||
check_param_number(const PGresult *res, int param_num)
|
||||
{
|
||||
if (!res)
|
||||
return FALSE; /* no way to display error message... */
|
||||
return false; /* no way to display error message... */
|
||||
if (param_num < 0 || param_num >= res->numParameters)
|
||||
{
|
||||
pqInternalNotice(&res->noticeHooks,
|
||||
"parameter number %d is out of range 0..%d",
|
||||
param_num, res->numParameters - 1);
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -3177,8 +3177,8 @@ PQparamtype(const PGresult *res, int param_num)
|
||||
|
||||
|
||||
/* PQsetnonblocking:
|
||||
* sets the PGconn's database connection non-blocking if the arg is TRUE
|
||||
* or makes it blocking if the arg is FALSE, this will not protect
|
||||
* sets the PGconn's database connection non-blocking if the arg is true
|
||||
* or makes it blocking if the arg is false, this will not protect
|
||||
* you from PQexec(), you'll only be safe when using the non-blocking API.
|
||||
* Needs to be called only on a connected database connection.
|
||||
*/
|
||||
@ -3190,7 +3190,7 @@ PQsetnonblocking(PGconn *conn, int arg)
|
||||
if (!conn || conn->status == CONNECTION_BAD)
|
||||
return -1;
|
||||
|
||||
barg = (arg ? TRUE : FALSE);
|
||||
barg = (arg ? true : false);
|
||||
|
||||
/* early out if the socket is already in the state requested */
|
||||
if (barg == conn->nonblocking)
|
||||
@ -3213,7 +3213,7 @@ PQsetnonblocking(PGconn *conn, int arg)
|
||||
|
||||
/*
|
||||
* return the blocking status of the database connection
|
||||
* TRUE == nonblocking, FALSE == blocking
|
||||
* true == nonblocking, false == blocking
|
||||
*/
|
||||
int
|
||||
PQisnonblocking(const PGconn *conn)
|
||||
|
@ -934,7 +934,7 @@ pqSendSome(PGconn *conn, int len)
|
||||
break;
|
||||
}
|
||||
|
||||
if (pqWait(TRUE, TRUE, conn))
|
||||
if (pqWait(true, true, conn))
|
||||
{
|
||||
result = -1;
|
||||
break;
|
||||
|
@ -583,7 +583,7 @@ pqParseInput2(PGconn *conn)
|
||||
if (conn->result != NULL)
|
||||
{
|
||||
/* Read another tuple of a normal query response */
|
||||
if (getAnotherTuple(conn, FALSE))
|
||||
if (getAnotherTuple(conn, false))
|
||||
return;
|
||||
/* getAnotherTuple() moves inStart itself */
|
||||
continue;
|
||||
@ -601,7 +601,7 @@ pqParseInput2(PGconn *conn)
|
||||
if (conn->result != NULL)
|
||||
{
|
||||
/* Read another tuple of a normal query response */
|
||||
if (getAnotherTuple(conn, TRUE))
|
||||
if (getAnotherTuple(conn, true))
|
||||
return;
|
||||
/* getAnotherTuple() moves inStart itself */
|
||||
continue;
|
||||
@ -679,7 +679,7 @@ getRowDescriptions(PGconn *conn)
|
||||
if (nfields > 0)
|
||||
{
|
||||
result->attDescs = (PGresAttDesc *)
|
||||
pqResultAlloc(result, nfields * sizeof(PGresAttDesc), TRUE);
|
||||
pqResultAlloc(result, nfields * sizeof(PGresAttDesc), true);
|
||||
if (!result->attDescs)
|
||||
{
|
||||
errmsg = NULL; /* means "out of memory", see below */
|
||||
@ -1218,7 +1218,7 @@ nodata:
|
||||
if (async)
|
||||
return 0;
|
||||
/* Need to load more data */
|
||||
if (pqWait(TRUE, FALSE, conn) ||
|
||||
if (pqWait(true, false, conn) ||
|
||||
pqReadData(conn) < 0)
|
||||
return -2;
|
||||
}
|
||||
@ -1263,7 +1263,7 @@ pqGetline2(PGconn *conn, char *s, int maxlen)
|
||||
else
|
||||
{
|
||||
/* need to load more data */
|
||||
if (pqWait(TRUE, FALSE, conn) ||
|
||||
if (pqWait(true, false, conn) ||
|
||||
pqReadData(conn) < 0)
|
||||
{
|
||||
result = EOF;
|
||||
@ -1484,7 +1484,7 @@ pqFunctionCall2(PGconn *conn, Oid fnid,
|
||||
if (needInput)
|
||||
{
|
||||
/* Wait for some data to arrive (or for the channel to close) */
|
||||
if (pqWait(TRUE, FALSE, conn) ||
|
||||
if (pqWait(true, false, conn) ||
|
||||
pqReadData(conn) < 0)
|
||||
break;
|
||||
}
|
||||
|
@ -510,7 +510,7 @@ getRowDescriptions(PGconn *conn, int msgLength)
|
||||
if (nfields > 0)
|
||||
{
|
||||
result->attDescs = (PGresAttDesc *)
|
||||
pqResultAlloc(result, nfields * sizeof(PGresAttDesc), TRUE);
|
||||
pqResultAlloc(result, nfields * sizeof(PGresAttDesc), true);
|
||||
if (!result->attDescs)
|
||||
{
|
||||
errmsg = NULL; /* means "out of memory", see below */
|
||||
@ -668,7 +668,7 @@ getParamDescriptions(PGconn *conn, int msgLength)
|
||||
if (nparams > 0)
|
||||
{
|
||||
result->paramDescs = (PGresParamDesc *)
|
||||
pqResultAlloc(result, nparams * sizeof(PGresParamDesc), TRUE);
|
||||
pqResultAlloc(result, nparams * sizeof(PGresParamDesc), true);
|
||||
if (!result->paramDescs)
|
||||
goto advance_and_error;
|
||||
MemSet(result->paramDescs, 0, nparams * sizeof(PGresParamDesc));
|
||||
@ -1466,7 +1466,7 @@ getCopyStart(PGconn *conn, ExecStatusType copytype)
|
||||
if (nfields > 0)
|
||||
{
|
||||
result->attDescs = (PGresAttDesc *)
|
||||
pqResultAlloc(result, nfields * sizeof(PGresAttDesc), TRUE);
|
||||
pqResultAlloc(result, nfields * sizeof(PGresAttDesc), true);
|
||||
if (!result->attDescs)
|
||||
goto failure;
|
||||
MemSet(result->attDescs, 0, nfields * sizeof(PGresAttDesc));
|
||||
@ -1657,7 +1657,7 @@ pqGetCopyData3(PGconn *conn, char **buffer, int async)
|
||||
if (async)
|
||||
return 0;
|
||||
/* Need to load more data */
|
||||
if (pqWait(TRUE, FALSE, conn) ||
|
||||
if (pqWait(true, false, conn) ||
|
||||
pqReadData(conn) < 0)
|
||||
return -2;
|
||||
continue;
|
||||
@ -1715,7 +1715,7 @@ pqGetline3(PGconn *conn, char *s, int maxlen)
|
||||
while ((status = PQgetlineAsync(conn, s, maxlen - 1)) == 0)
|
||||
{
|
||||
/* need to load more data */
|
||||
if (pqWait(TRUE, FALSE, conn) ||
|
||||
if (pqWait(true, false, conn) ||
|
||||
pqReadData(conn) < 0)
|
||||
{
|
||||
*s = '\0';
|
||||
@ -1968,7 +1968,7 @@ pqFunctionCall3(PGconn *conn, Oid fnid,
|
||||
if (needInput)
|
||||
{
|
||||
/* Wait for some data to arrive (or for the channel to close) */
|
||||
if (pqWait(TRUE, FALSE, conn) ||
|
||||
if (pqWait(true, false, conn) ||
|
||||
pqReadData(conn) < 0)
|
||||
break;
|
||||
}
|
||||
|
@ -465,10 +465,10 @@ pq_block_sigpipe(sigset_t *osigset, bool *sigpipe_pending)
|
||||
* As long as it doesn't queue multiple events, we're OK because the caller
|
||||
* can't tell the difference.
|
||||
*
|
||||
* The caller should say got_epipe = FALSE if it is certain that it
|
||||
* The caller should say got_epipe = false if it is certain that it
|
||||
* didn't get an EPIPE error; in that case we'll skip the clear operation
|
||||
* and things are definitely OK, queuing or no. If it got one or might have
|
||||
* gotten one, pass got_epipe = TRUE.
|
||||
* gotten one, pass got_epipe = true.
|
||||
*
|
||||
* We do not want this to change errno, since if it did that could lose
|
||||
* the error code from a preceding send(). We essentially assume that if
|
||||
|
@ -44,12 +44,12 @@ PQregisterEventProc(PGconn *conn, PGEventProc proc,
|
||||
PGEventRegister regevt;
|
||||
|
||||
if (!proc || !conn || !name || !*name)
|
||||
return FALSE; /* bad arguments */
|
||||
return false; /* bad arguments */
|
||||
|
||||
for (i = 0; i < conn->nEvents; i++)
|
||||
{
|
||||
if (conn->events[i].proc == proc)
|
||||
return FALSE; /* already registered */
|
||||
return false; /* already registered */
|
||||
}
|
||||
|
||||
if (conn->nEvents >= conn->eventArraySize)
|
||||
@ -64,7 +64,7 @@ PQregisterEventProc(PGconn *conn, PGEventProc proc,
|
||||
e = (PGEvent *) malloc(newSize * sizeof(PGEvent));
|
||||
|
||||
if (!e)
|
||||
return FALSE;
|
||||
return false;
|
||||
|
||||
conn->eventArraySize = newSize;
|
||||
conn->events = e;
|
||||
@ -73,10 +73,10 @@ PQregisterEventProc(PGconn *conn, PGEventProc proc,
|
||||
conn->events[conn->nEvents].proc = proc;
|
||||
conn->events[conn->nEvents].name = strdup(name);
|
||||
if (!conn->events[conn->nEvents].name)
|
||||
return FALSE;
|
||||
return false;
|
||||
conn->events[conn->nEvents].passThrough = passThrough;
|
||||
conn->events[conn->nEvents].data = NULL;
|
||||
conn->events[conn->nEvents].resultInitialized = FALSE;
|
||||
conn->events[conn->nEvents].resultInitialized = false;
|
||||
conn->nEvents++;
|
||||
|
||||
regevt.conn = conn;
|
||||
@ -84,10 +84,10 @@ PQregisterEventProc(PGconn *conn, PGEventProc proc,
|
||||
{
|
||||
conn->nEvents--;
|
||||
free(conn->events[conn->nEvents].name);
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -100,18 +100,18 @@ PQsetInstanceData(PGconn *conn, PGEventProc proc, void *data)
|
||||
int i;
|
||||
|
||||
if (!conn || !proc)
|
||||
return FALSE;
|
||||
return false;
|
||||
|
||||
for (i = 0; i < conn->nEvents; i++)
|
||||
{
|
||||
if (conn->events[i].proc == proc)
|
||||
{
|
||||
conn->events[i].data = data;
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -144,18 +144,18 @@ PQresultSetInstanceData(PGresult *result, PGEventProc proc, void *data)
|
||||
int i;
|
||||
|
||||
if (!result || !proc)
|
||||
return FALSE;
|
||||
return false;
|
||||
|
||||
for (i = 0; i < result->nEvents; i++)
|
||||
{
|
||||
if (result->events[i].proc == proc)
|
||||
{
|
||||
result->events[i].data = data;
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -187,7 +187,7 @@ PQfireResultCreateEvents(PGconn *conn, PGresult *res)
|
||||
int i;
|
||||
|
||||
if (!res)
|
||||
return FALSE;
|
||||
return false;
|
||||
|
||||
for (i = 0; i < res->nEvents; i++)
|
||||
{
|
||||
@ -199,11 +199,11 @@ PQfireResultCreateEvents(PGconn *conn, PGresult *res)
|
||||
evt.result = res;
|
||||
if (!res->events[i].proc(PGEVT_RESULTCREATE, &evt,
|
||||
res->events[i].passThrough))
|
||||
return FALSE;
|
||||
return false;
|
||||
|
||||
res->events[i].resultInitialized = TRUE;
|
||||
res->events[i].resultInitialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user