aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/dbcommands.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2008-11-02 01:45:28 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2008-11-02 01:45:28 +0000
commit902d1cb35f69464e1e13015b9e05abdb76a7444d (patch)
tree995e1ec29c8a937a3890956065a31c1ab9d7c6bd /src/backend/commands/dbcommands.c
parent492059dabae9643f097fcd0a4f8860366563843d (diff)
downloadpostgresql-902d1cb35f69464e1e13015b9e05abdb76a7444d.tar.gz
postgresql-902d1cb35f69464e1e13015b9e05abdb76a7444d.zip
Remove all uses of the deprecated functions heap_formtuple, heap_modifytuple,
and heap_deformtuple in favor of the newer functions heap_form_tuple et al (which do the same things but use bool control flags instead of arbitrary char values). Eliminate the former duplicate coding of these functions, reducing the deprecated functions to mere wrappers around the newer ones. We can't get rid of them entirely because add-on modules probably still contain many instances of the old coding style. Kris Jurka
Diffstat (limited to 'src/backend/commands/dbcommands.c')
-rw-r--r--src/backend/commands/dbcommands.c54
1 files changed, 27 insertions, 27 deletions
diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c
index 1efe0c3777b..7eb6e1bda00 100644
--- a/src/backend/commands/dbcommands.c
+++ b/src/backend/commands/dbcommands.c
@@ -13,7 +13,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.214 2008/10/09 10:34:06 heikki Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.215 2008/11/02 01:45:27 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -98,7 +98,7 @@ createdb(const CreatedbStmt *stmt)
Relation pg_database_rel;
HeapTuple tuple;
Datum new_record[Natts_pg_database];
- char new_record_nulls[Natts_pg_database];
+ bool new_record_nulls[Natts_pg_database];
Oid dboid;
Oid datdba;
ListCell *option;
@@ -492,7 +492,7 @@ createdb(const CreatedbStmt *stmt)
/* Form tuple */
MemSet(new_record, 0, sizeof(new_record));
- MemSet(new_record_nulls, ' ', sizeof(new_record_nulls));
+ MemSet(new_record_nulls, false, sizeof(new_record_nulls));
new_record[Anum_pg_database_datname - 1] =
DirectFunctionCall1(namein, CStringGetDatum(dbname));
@@ -515,10 +515,10 @@ createdb(const CreatedbStmt *stmt)
* a bad idea when the owner is not the same as the template's owner. It's
* more debatable whether datconfig should be copied.
*/
- new_record_nulls[Anum_pg_database_datconfig - 1] = 'n';
- new_record_nulls[Anum_pg_database_datacl - 1] = 'n';
+ new_record_nulls[Anum_pg_database_datconfig - 1] = true;
+ new_record_nulls[Anum_pg_database_datacl - 1] = true;
- tuple = heap_formtuple(RelationGetDescr(pg_database_rel),
+ tuple = heap_form_tuple(RelationGetDescr(pg_database_rel),
new_record, new_record_nulls);
HeapTupleSetOid(tuple, dboid);
@@ -949,8 +949,8 @@ AlterDatabase(AlterDatabaseStmt *stmt)
int connlimit = -1;
DefElem *dconnlimit = NULL;
Datum new_record[Natts_pg_database];
- char new_record_nulls[Natts_pg_database];
- char new_record_repl[Natts_pg_database];
+ bool new_record_nulls[Natts_pg_database];
+ bool new_record_repl[Natts_pg_database];
/* Extract options from the statement node tree */
foreach(option, stmt->options)
@@ -999,16 +999,16 @@ AlterDatabase(AlterDatabaseStmt *stmt)
* Build an updated tuple, perusing the information just obtained
*/
MemSet(new_record, 0, sizeof(new_record));
- MemSet(new_record_nulls, ' ', sizeof(new_record_nulls));
- MemSet(new_record_repl, ' ', sizeof(new_record_repl));
+ MemSet(new_record_nulls, false, sizeof(new_record_nulls));
+ MemSet(new_record_repl, false, sizeof(new_record_repl));
if (dconnlimit)
{
new_record[Anum_pg_database_datconnlimit - 1] = Int32GetDatum(connlimit);
- new_record_repl[Anum_pg_database_datconnlimit - 1] = 'r';
+ new_record_repl[Anum_pg_database_datconnlimit - 1] = true;
}
- newtuple = heap_modifytuple(tuple, RelationGetDescr(rel), new_record,
+ newtuple = heap_modify_tuple(tuple, RelationGetDescr(rel), new_record,
new_record_nulls, new_record_repl);
simple_heap_update(rel, &tuple->t_self, newtuple);
@@ -1040,8 +1040,8 @@ AlterDatabaseSet(AlterDatabaseSetStmt *stmt)
ScanKeyData scankey;
SysScanDesc scan;
Datum repl_val[Natts_pg_database];
- char repl_null[Natts_pg_database];
- char repl_repl[Natts_pg_database];
+ bool repl_null[Natts_pg_database];
+ bool repl_repl[Natts_pg_database];
valuestr = ExtractSetVariableArgs(stmt->setstmt);
@@ -1067,13 +1067,13 @@ AlterDatabaseSet(AlterDatabaseSetStmt *stmt)
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_DATABASE,
stmt->dbname);
- memset(repl_repl, ' ', sizeof(repl_repl));
- repl_repl[Anum_pg_database_datconfig - 1] = 'r';
+ memset(repl_repl, false, sizeof(repl_repl));
+ repl_repl[Anum_pg_database_datconfig - 1] = true;
if (stmt->setstmt->kind == VAR_RESET_ALL)
{
/* RESET ALL, so just set datconfig to null */
- repl_null[Anum_pg_database_datconfig - 1] = 'n';
+ repl_null[Anum_pg_database_datconfig - 1] = true;
repl_val[Anum_pg_database_datconfig - 1] = (Datum) 0;
}
else
@@ -1082,7 +1082,7 @@ AlterDatabaseSet(AlterDatabaseSetStmt *stmt)
bool isnull;
ArrayType *a;
- repl_null[Anum_pg_database_datconfig - 1] = ' ';
+ repl_null[Anum_pg_database_datconfig - 1] = false;
/* Extract old value of datconfig */
datum = heap_getattr(tuple, Anum_pg_database_datconfig,
@@ -1098,10 +1098,10 @@ AlterDatabaseSet(AlterDatabaseSetStmt *stmt)
if (a)
repl_val[Anum_pg_database_datconfig - 1] = PointerGetDatum(a);
else
- repl_null[Anum_pg_database_datconfig - 1] = 'n';
+ repl_null[Anum_pg_database_datconfig - 1] = true;
}
- newtuple = heap_modifytuple(tuple, RelationGetDescr(rel),
+ newtuple = heap_modify_tuple(tuple, RelationGetDescr(rel),
repl_val, repl_null, repl_repl);
simple_heap_update(rel, &tuple->t_self, newtuple);
@@ -1160,8 +1160,8 @@ AlterDatabaseOwner(const char *dbname, Oid newOwnerId)
if (datForm->datdba != newOwnerId)
{
Datum repl_val[Natts_pg_database];
- char repl_null[Natts_pg_database];
- char repl_repl[Natts_pg_database];
+ bool repl_null[Natts_pg_database];
+ bool repl_repl[Natts_pg_database];
Acl *newAcl;
Datum aclDatum;
bool isNull;
@@ -1189,10 +1189,10 @@ AlterDatabaseOwner(const char *dbname, Oid newOwnerId)
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
errmsg("permission denied to change owner of database")));
- memset(repl_null, ' ', sizeof(repl_null));
- memset(repl_repl, ' ', sizeof(repl_repl));
+ memset(repl_null, false, sizeof(repl_null));
+ memset(repl_repl, false, sizeof(repl_repl));
- repl_repl[Anum_pg_database_datdba - 1] = 'r';
+ repl_repl[Anum_pg_database_datdba - 1] = true;
repl_val[Anum_pg_database_datdba - 1] = ObjectIdGetDatum(newOwnerId);
/*
@@ -1207,11 +1207,11 @@ AlterDatabaseOwner(const char *dbname, Oid newOwnerId)
{
newAcl = aclnewowner(DatumGetAclP(aclDatum),
datForm->datdba, newOwnerId);
- repl_repl[Anum_pg_database_datacl - 1] = 'r';
+ repl_repl[Anum_pg_database_datacl - 1] = true;
repl_val[Anum_pg_database_datacl - 1] = PointerGetDatum(newAcl);
}
- newtuple = heap_modifytuple(tuple, RelationGetDescr(rel), repl_val, repl_null, repl_repl);
+ newtuple = heap_modify_tuple(tuple, RelationGetDescr(rel), repl_val, repl_null, repl_repl);
simple_heap_update(rel, &newtuple->t_self, newtuple);
CatalogUpdateIndexes(rel, newtuple);