Fix snprintf with strings, and nextval('"Aa"');

This commit is contained in:
Bruce Momjian 1999-03-16 04:26:01 +00:00
parent 434762b559
commit 89b762e509
7 changed files with 6454 additions and 6451 deletions

View File

@ -7,7 +7,7 @@
*
*
* 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);
for (i = 1; i < parameterCount; i++)
snprintf(newquery, 1000, "%s,$%d", newquery, i);
snprintf(newquery, 1000, "%s)", newquery);
snprintf(newquery, 1000, "%s,$%d", pstrdup(newquery), i);
snprintf(newquery, 1000, "%s)", pstrdup(newquery));
}
else
snprintf(newquery, 1000, "select %s()", funcName);

View File

@ -7,7 +7,7 @@
*
*
* 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,
"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);
}

View File

@ -5,7 +5,7 @@
*
* 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)
{
snprintf(sql, SQL_LENGTH, "%s passwd = '%s'", sql, stmt->password);
snprintf(sql, SQL_LENGTH, "%s passwd = '%s'", pstrdup(sql), stmt->password);
}
if (stmt->createdb)
{
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)
{
snprintf(sql, SQL_LENGTH, "%s %susesuper='%s'",
sql, (stmt->password || stmt->createdb) ? "," : "",
pstrdup(sql), (stmt->password || stmt->createdb) ? "," : "",
*stmt->createuser ? "t" : "f");
}
if (stmt->validUntil)
{
snprintf(sql, SQL_LENGTH, "%s %svaluntil='%s'",
sql,
pstrdup(sql),
(stmt->password || stmt->createdb || stmt->createuser) ? "," : "",
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);

File diff suppressed because it is too large Load Diff

View File

@ -7,7 +7,7 @@
*
*
* 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);
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);
seqname = lower((text *) DatumGetPointer(seq->constvalue));

View File

@ -138,7 +138,7 @@ tprintf1(const char *fmt, ... )
#ifdef ELOG_TIMESTAMPS
strcpy(line, tprintf_timestamp());
#endif
vsnprintf(line+TIMESTAMP_SIZE, ELOG_MAXLEN, fmt, ap);
vsnprintf(line + TIMESTAMP_SIZE, ELOG_MAXLEN, fmt, ap);
va_end(ap);
#ifdef USE_SYSLOG

File diff suppressed because it is too large Load Diff