mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-02-17 19:30:00 +08:00
Fix snprintf with strings, and nextval('"Aa"');
This commit is contained in:
parent
434762b559
commit
89b762e509
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/commands/_deadcode/Attic/recipe.c,v 1.1 1999/02/24 17:29:00 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/commands/_deadcode/Attic/recipe.c,v 1.2 1999/03/16 04:25:46 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -878,8 +878,8 @@ tg_parseSubQuery(TgRecipe * r, TgNode * n, TeeInfo * teeInfo)
|
|||||||
|
|
||||||
snprintf(newquery, 1000, "select %s($1", funcName);
|
snprintf(newquery, 1000, "select %s($1", funcName);
|
||||||
for (i = 1; i < parameterCount; i++)
|
for (i = 1; i < parameterCount; i++)
|
||||||
snprintf(newquery, 1000, "%s,$%d", newquery, i);
|
snprintf(newquery, 1000, "%s,$%d", pstrdup(newquery), i);
|
||||||
snprintf(newquery, 1000, "%s)", newquery);
|
snprintf(newquery, 1000, "%s)", pstrdup(newquery));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
snprintf(newquery, 1000, "select %s()", funcName);
|
snprintf(newquery, 1000, "select %s()", funcName);
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.32 1999/03/16 03:24:16 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.33 1999/03/16 04:25:45 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -85,7 +85,8 @@ createdb(char *dbname, char *dbpath, int encoding, CommandDest dest)
|
|||||||
|
|
||||||
snprintf(buf, 512,
|
snprintf(buf, 512,
|
||||||
"insert into pg_database (datname, datdba, encoding, datpath)"
|
"insert into pg_database (datname, datdba, encoding, datpath)"
|
||||||
" values ('%s', '%d', '%d', '%s');", dbname, user_id, encoding, loc);
|
" values ('%s', '%d', '%d', '%s');", dbname, user_id, encoding,
|
||||||
|
loc);
|
||||||
|
|
||||||
pg_exec_query_dest(buf, dest, false);
|
pg_exec_query_dest(buf, dest, false);
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright (c) 1994, Regents of the University of California
|
* Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $Id: user.c,v 1.25 1999/03/16 03:24:16 momjian Exp $
|
* $Id: user.c,v 1.26 1999/03/16 04:25:45 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -256,31 +256,33 @@ AlterUser(AlterUserStmt *stmt, CommandDest dest)
|
|||||||
|
|
||||||
if (stmt->password)
|
if (stmt->password)
|
||||||
{
|
{
|
||||||
snprintf(sql, SQL_LENGTH, "%s passwd = '%s'", sql, stmt->password);
|
snprintf(sql, SQL_LENGTH, "%s passwd = '%s'", pstrdup(sql), stmt->password);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stmt->createdb)
|
if (stmt->createdb)
|
||||||
{
|
{
|
||||||
snprintf(sql, SQL_LENGTH, "%s %susecreatedb='%s'",
|
snprintf(sql, SQL_LENGTH, "%s %susecreatedb='%s'",
|
||||||
sql, stmt->password ? "," : "", *stmt->createdb ? "t" : "f");
|
pstrdup(sql), stmt->password ? "," : "",
|
||||||
|
*stmt->createdb ? "t" : "f");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stmt->createuser)
|
if (stmt->createuser)
|
||||||
{
|
{
|
||||||
snprintf(sql, SQL_LENGTH, "%s %susesuper='%s'",
|
snprintf(sql, SQL_LENGTH, "%s %susesuper='%s'",
|
||||||
sql, (stmt->password || stmt->createdb) ? "," : "",
|
pstrdup(sql), (stmt->password || stmt->createdb) ? "," : "",
|
||||||
*stmt->createuser ? "t" : "f");
|
*stmt->createuser ? "t" : "f");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stmt->validUntil)
|
if (stmt->validUntil)
|
||||||
{
|
{
|
||||||
snprintf(sql, SQL_LENGTH, "%s %svaluntil='%s'",
|
snprintf(sql, SQL_LENGTH, "%s %svaluntil='%s'",
|
||||||
sql,
|
pstrdup(sql),
|
||||||
(stmt->password || stmt->createdb || stmt->createuser) ? "," : "",
|
(stmt->password || stmt->createdb || stmt->createuser) ? "," : "",
|
||||||
stmt->validUntil);
|
stmt->validUntil);
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(sql, SQL_LENGTH, "%s where usename = '%s'", sql, stmt->user);
|
snprintf(sql, SQL_LENGTH, "%s where usename = '%s'",
|
||||||
|
pstrdup(sql), stmt->user);
|
||||||
|
|
||||||
pg_exec_query_dest(sql, dest, false);
|
pg_exec_query_dest(sql, dest, false);
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.40 1999/03/15 16:48:34 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.41 1999/03/16 04:25:54 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -580,7 +580,15 @@ ParseFuncOrColumn(ParseState *pstate, char *funcname, List *fargs,
|
|||||||
elog(ERROR, "Only constant sequence names are acceptable for function '%s'", funcname);
|
elog(ERROR, "Only constant sequence names are acceptable for function '%s'", funcname);
|
||||||
|
|
||||||
seqrel = textout((text *) DatumGetPointer(seq->constvalue));
|
seqrel = textout((text *) DatumGetPointer(seq->constvalue));
|
||||||
if (RelnameFindRelid(seqrel) == InvalidOid)
|
/* Do we have nextval('"Aa"')? */
|
||||||
|
if (strlen(seqrel) >= 2 &&
|
||||||
|
seqrel[0] == '\"' && seqrel[strlen(seqrel)-1] == '\"')
|
||||||
|
{
|
||||||
|
/* strip off quotes, keep case */
|
||||||
|
seqrel = pstrdup(seqrel+1);
|
||||||
|
seqrel[strlen(seqrel)-1] = '\0';
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
pfree(seqrel);
|
pfree(seqrel);
|
||||||
seqname = lower((text *) DatumGetPointer(seq->constvalue));
|
seqname = lower((text *) DatumGetPointer(seq->constvalue));
|
||||||
|
@ -138,7 +138,7 @@ tprintf1(const char *fmt, ... )
|
|||||||
#ifdef ELOG_TIMESTAMPS
|
#ifdef ELOG_TIMESTAMPS
|
||||||
strcpy(line, tprintf_timestamp());
|
strcpy(line, tprintf_timestamp());
|
||||||
#endif
|
#endif
|
||||||
vsnprintf(line+TIMESTAMP_SIZE, ELOG_MAXLEN, fmt, ap);
|
vsnprintf(line + TIMESTAMP_SIZE, ELOG_MAXLEN, fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
#ifdef USE_SYSLOG
|
#ifdef USE_SYSLOG
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user