1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-30 11:03:19 +03:00

Replace pg_asprintf() with psprintf().

This eliminates an awkward coding pattern that's also unnecessarily
inconsistent with backend coding.  psprintf() is now the thing to
use everywhere.
This commit is contained in:
Tom Lane
2013-10-22 19:40:26 -04:00
parent 09a89cb5fc
commit 2c66f9924c
19 changed files with 57 additions and 125 deletions

View File

@ -508,7 +508,7 @@ sql_exec_searchtables(PGconn *conn, struct options * opts)
free(comma_filenodes);
/* now build the query */
pg_asprintf(&todo,
todo = psprintf(
"SELECT pg_catalog.pg_relation_filenode(c.oid) as \"Filenode\", relname as \"Table Name\" %s\n"
"FROM pg_catalog.pg_class c \n"
" LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace \n"

View File

@ -458,10 +458,9 @@ create_script_for_cluster_analyze(char **analyze_script_file_name)
prep_status("Creating script to analyze new cluster");
if (os_info.user_specified)
pg_asprintf(&user_specification, "-U \"%s\" ", os_info.user);
user_specification = psprintf("-U \"%s\" ", os_info.user);
pg_asprintf(analyze_script_file_name, "analyze_new_cluster.%s",
SCRIPT_EXT);
*analyze_script_file_name = psprintf("analyze_new_cluster.%s", SCRIPT_EXT);
if ((script = fopen_priv(*analyze_script_file_name, "w")) == NULL)
pg_fatal("Could not open file \"%s\": %s\n",
@ -592,8 +591,7 @@ create_script_for_old_cluster_deletion(char **deletion_script_file_name)
int tblnum;
char old_cluster_pgdata[MAXPGPATH];
pg_asprintf(deletion_script_file_name, "delete_old_cluster.%s",
SCRIPT_EXT);
*deletion_script_file_name = psprintf("delete_old_cluster.%s", SCRIPT_EXT);
/*
* Some users (oddly) create tablespaces inside the cluster data

View File

@ -86,7 +86,8 @@ set_tablespace_directory_suffix(ClusterInfo *cluster)
/* This cluster has a version-specific subdirectory */
/* The leading slash is needed to start a new directory. */
pg_asprintf(&cluster->tablespace_suffix, "/PG_%s_%d",
cluster->major_version_str, cluster->controldata.cat_ver);
cluster->tablespace_suffix = psprintf("/PG_%s_%d",
cluster->major_version_str,
cluster->controldata.cat_ver);
}
}

View File

@ -278,7 +278,7 @@ pg_putenv(const char *var, const char *val)
#ifndef WIN32
char *envstr;
pg_asprintf(&envstr, "%s=%s", var, val);
envstr = psprintf("%s=%s", var, val);
putenv(envstr);
/*