1
0
mirror of https://github.com/postgres/postgres.git synced 2025-12-22 17:42:17 +03:00

Update textin() and textout() to new fmgr style. This is just phase

one of updating the whole text datatype, but there are so dang many
calls of these two routines that it seems worth a separate commit.
This commit is contained in:
Tom Lane
2000-07-05 23:12:09 +00:00
parent 282713a836
commit 40f64064ff
39 changed files with 286 additions and 271 deletions

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/analyze.c,v 1.2 2000/05/30 04:25:00 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/analyze.c,v 1.3 2000/07/05 23:11:08 tgl Exp $
*
*-------------------------------------------------------------------------
@@ -515,8 +515,8 @@ update_attstats(Oid relid, int natts, VacAttrStats *vacattrstats)
*/
if (VacAttrStatsLtGtValid(stats) && stats->initialized)
{
float32data nullratio;
float32data bestratio;
float4 nullratio;
float4 bestratio;
FmgrInfo out_function;
char *out_string;
double best_cnt_d = stats->best_cnt,
@@ -541,26 +541,28 @@ update_attstats(Oid relid, int natts, VacAttrStats *vacattrstats)
values[i++] = ObjectIdGetDatum(relid); /* starelid */
values[i++] = Int16GetDatum(attp->attnum); /* staattnum */
values[i++] = ObjectIdGetDatum(stats->op_cmplt); /* staop */
/* hack: this code knows float4 is pass-by-ref */
values[i++] = Float32GetDatum(&nullratio); /* stanullfrac */
values[i++] = Float32GetDatum(&bestratio); /* stacommonfrac */
values[i++] = Float4GetDatum(nullratio); /* stanullfrac */
values[i++] = Float4GetDatum(bestratio); /* stacommonfrac */
out_string = DatumGetCString(FunctionCall3(&out_function,
stats->best,
ObjectIdGetDatum(stats->typelem),
Int32GetDatum(stats->attr->atttypmod)));
values[i++] = PointerGetDatum(textin(out_string)); /* stacommonval */
values[i++] = DirectFunctionCall1(textin, /* stacommonval */
CStringGetDatum(out_string));
pfree(out_string);
out_string = DatumGetCString(FunctionCall3(&out_function,
stats->min,
ObjectIdGetDatum(stats->typelem),
Int32GetDatum(stats->attr->atttypmod)));
values[i++] = PointerGetDatum(textin(out_string)); /* staloval */
values[i++] = DirectFunctionCall1(textin, /* staloval */
CStringGetDatum(out_string));
pfree(out_string);
out_string = DatumGetCString(FunctionCall3(&out_function,
stats->max,
ObjectIdGetDatum(stats->typelem),
Int32GetDatum(stats->attr->atttypmod)));
values[i++] = PointerGetDatum(textin(out_string)); /* stahival */
values[i++] = DirectFunctionCall1(textin, /* stahival */
CStringGetDatum(out_string));
pfree(out_string);
stup = heap_formtuple(sd->rd_att, values, nulls);

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.87 2000/07/05 16:17:38 wieck Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.88 2000/07/05 23:11:09 tgl Exp $
*
* NOTES
* The PerformAddAttribute() code, like most of the relation
@@ -788,7 +788,6 @@ RemoveColumnReferences(Oid reloid, int attnum, bool checkonly, HeapTuple reltup)
HeapTuple htup,
indexTuple;
Form_pg_index index;
Form_pg_relcheck relcheck;
Form_pg_class pgcform = (Form_pg_class) NULL;
int i;
bool checkok = true;
@@ -807,13 +806,13 @@ RemoveColumnReferences(Oid reloid, int attnum, bool checkonly, HeapTuple reltup)
while (HeapTupleIsValid(htup = systable_getnext(sysscan)))
{
Form_pg_relcheck relcheck;
char *ccbin;
Node *node;
relcheck = (Form_pg_relcheck) GETSTRUCT(htup);
ccbin = textout(&relcheck->rcbin);
if (!ccbin)
continue;
ccbin = DatumGetCString(DirectFunctionCall1(textout,
PointerGetDatum(&relcheck->rcbin)));
node = stringToNode(ccbin);
pfree(ccbin);
if (find_attribute_in_node(node, attnum))
@@ -1322,10 +1321,12 @@ AlterTableCreateToastTable(const char *relationName, bool silent)
BYTEAOID,
-1, 0, false);
/* XXX what if owning relation is temp? need we mark toasttable too? */
/* XXX How do we know? No naming collisions possible because names */
/* are OID based. And toast table disappears when master table */
/* is destroyed. So what is it good for anyway? Jan */
/*
* Note: the toast relation is considered a "normal" relation even if
* its master relation is a temp table. There cannot be any naming
* collision, and the toast rel will be destroyed when its master is,
* so there's no need to handle the toast rel as temp.
*/
heap_create_with_catalog(toast_relname, tupdesc, RELKIND_TOASTVALUE,
false, true);
@@ -1399,7 +1400,7 @@ AlterTableCreateToastTable(const char *relationName, bool silent)
heap_freetuple(reltup);
/*
* Close relatons and make changes visible
* Close relations and make changes visible
*/
heap_close(class_rel, NoLock);
heap_close(rel, NoLock);

View File

@@ -151,7 +151,7 @@ CreateComments(Oid oid, char *comment)
}
i = 0;
values[i++] = ObjectIdGetDatum(oid);
values[i++] = (Datum) textin(comment);
values[i++] = DirectFunctionCall1(textin, CStringGetDatum(comment));
}
/*** Now, open pg_description and attempt to find the old tuple ***/

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.116 2000/06/28 06:05:36 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.117 2000/07/05 23:11:11 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -676,7 +676,8 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim, char *null
indexNatts[i] = natts;
if (VARSIZE(&pgIndexP[i]->indpred) != 0)
{
predString = textout(&pgIndexP[i]->indpred);
predString = DatumGetCString(DirectFunctionCall1(textout,
PointerGetDatum(&pgIndexP[i]->indpred)));
indexPred[i] = stringToNode(predString);
pfree(predString);
/* make dummy ExprContext for use by ExecQual */

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.57 2000/06/02 04:04:54 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.58 2000/07/05 23:11:11 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -101,7 +101,8 @@ createdb(const char *dbname, const char *dbpath, int encoding)
new_record[Anum_pg_database_datname - 1] = NameGetDatum(namein(dbname));
new_record[Anum_pg_database_datdba - 1] = Int32GetDatum(user_id);
new_record[Anum_pg_database_encoding - 1] = Int32GetDatum(encoding);
new_record[Anum_pg_database_datpath - 1] = PointerGetDatum(textin(locbuf));
new_record[Anum_pg_database_datpath - 1] = DirectFunctionCall1(textin,
CStringGetDatum(locbuf));
tuple = heap_formtuple(pg_database_dsc, new_record, new_record_nulls);

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.33 2000/07/04 06:11:27 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.34 2000/07/05 23:11:11 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -304,7 +304,8 @@ ExtendIndex(char *indexRelationName, Expr *predicate, List *rangetable)
{
char *predString;
predString = textout(&index->indpred);
predString = DatumGetCString(DirectFunctionCall1(textout,
PointerGetDatum(&index->indpred)));
oldPred = stringToNode(predString);
pfree(predString);
}

View File

@@ -117,10 +117,11 @@ CreateProceduralLanguage(CreatePLangStmt *stmt)
i = 0;
values[i++] = PointerGetDatum(languageName);
values[i++] = Int8GetDatum((bool) 1);
values[i++] = Int8GetDatum(stmt->pltrusted);
values[i++] = BoolGetDatum(true); /* lanispl */
values[i++] = BoolGetDatum(stmt->pltrusted);
values[i++] = ObjectIdGetDatum(procTup->t_data->t_oid);
values[i++] = (Datum) textin(stmt->plcompiler);
values[i++] = DirectFunctionCall1(textin,
CStringGetDatum(stmt->plcompiler));
rel = heap_openr(LanguageRelationName, RowExclusiveLock);

View File

@@ -377,7 +377,8 @@ setval(PG_FUNCTION_ARGS)
static char *
get_seq_name(text *seqin)
{
char *rawname = textout(seqin);
char *rawname = DatumGetCString(DirectFunctionCall1(textout,
PointerGetDatum(seqin)));
int rawlen = strlen(rawname);
char *seqname;

View File

@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Header: /cvsroot/pgsql/src/backend/commands/user.c,v 1.62 2000/06/28 03:31:28 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/user.c,v 1.63 2000/07/05 23:11:11 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -121,7 +121,8 @@ write_password_file(Relation rel)
CRYPT_PWD_FILE_SEPSTR
"%s\n",
nameout(DatumGetName(datum_n)),
null_p ? "" : textout((text *) datum_p),
null_p ? "" :
DatumGetCString(DirectFunctionCall1(textout, datum_p)),
null_v ? "\\N" :
DatumGetCString(DirectFunctionCall1(nabstimeout, datum_v))
);
@@ -257,7 +258,8 @@ CreateUser(CreateUserStmt *stmt)
new_record[Anum_pg_shadow_usecatupd - 1] = (Datum) (stmt->createuser);
if (stmt->password)
new_record[Anum_pg_shadow_passwd - 1] = PointerGetDatum(textin(stmt->password));
new_record[Anum_pg_shadow_passwd - 1] =
DirectFunctionCall1(textin, CStringGetDatum(stmt->password));
if (stmt->validUntil)
new_record[Anum_pg_shadow_valuntil - 1] =
DirectFunctionCall1(nabstimein, CStringGetDatum(stmt->validUntil));
@@ -424,13 +426,15 @@ AlterUser(AlterUserStmt *stmt)
/* password */
if (stmt->password)
{
new_record[Anum_pg_shadow_passwd - 1] = PointerGetDatum(textin(stmt->password));
new_record[Anum_pg_shadow_passwd - 1] =
DirectFunctionCall1(textin, CStringGetDatum(stmt->password));
new_record_nulls[Anum_pg_shadow_passwd - 1] = ' ';
}
else
{
/* leave as is */
new_record[Anum_pg_shadow_passwd - 1] = heap_getattr(tuple, Anum_pg_shadow_passwd, pg_shadow_dsc, &null);
new_record[Anum_pg_shadow_passwd - 1] =
heap_getattr(tuple, Anum_pg_shadow_passwd, pg_shadow_dsc, &null);
new_record_nulls[Anum_pg_shadow_passwd - 1] = null ? 'n' : ' ';
}
@@ -444,7 +448,8 @@ AlterUser(AlterUserStmt *stmt)
else
{
/* leave as is */
new_record[Anum_pg_shadow_valuntil - 1] = heap_getattr(tuple, Anum_pg_shadow_valuntil, pg_shadow_dsc, &null);
new_record[Anum_pg_shadow_valuntil - 1] =
heap_getattr(tuple, Anum_pg_shadow_valuntil, pg_shadow_dsc, &null);
new_record_nulls[Anum_pg_shadow_valuntil - 1] = null ? 'n' : ' ';
}