diff options
Diffstat (limited to 'src/backend/commands/dbcommands.c')
-rw-r--r-- | src/backend/commands/dbcommands.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c index e950e4c458a..5a6c9beaa47 100644 --- a/src/backend/commands/dbcommands.c +++ b/src/backend/commands/dbcommands.c @@ -570,10 +570,8 @@ createdb(ParseState *pstate, const CreatedbStmt *stmt) DirectFunctionCall1(namein, CStringGetDatum(dbname)); new_record[Anum_pg_database_datdba - 1] = ObjectIdGetDatum(datdba); new_record[Anum_pg_database_encoding - 1] = Int32GetDatum(encoding); - new_record[Anum_pg_database_datcollate - 1] = - DirectFunctionCall1(namein, CStringGetDatum(dbcollate)); - new_record[Anum_pg_database_datctype - 1] = - DirectFunctionCall1(namein, CStringGetDatum(dbctype)); + new_record[Anum_pg_database_datcollate - 1] = CStringGetTextDatum(dbcollate); + new_record[Anum_pg_database_datctype - 1] = CStringGetTextDatum(dbctype); new_record[Anum_pg_database_datistemplate - 1] = BoolGetDatum(dbistemplate); new_record[Anum_pg_database_datallowconn - 1] = BoolGetDatum(dballowconnections); new_record[Anum_pg_database_datconnlimit - 1] = Int32GetDatum(dbconnlimit); @@ -1867,6 +1865,9 @@ get_db_info(const char *name, LOCKMODE lockmode, if (strcmp(name, NameStr(dbform->datname)) == 0) { + Datum datum; + bool isnull; + /* oid of the database */ if (dbIdP) *dbIdP = dbOid; @@ -1893,9 +1894,17 @@ get_db_info(const char *name, LOCKMODE lockmode, *dbTablespace = dbform->dattablespace; /* default locale settings for this database */ if (dbCollate) - *dbCollate = pstrdup(NameStr(dbform->datcollate)); + { + datum = SysCacheGetAttr(DATABASEOID, tuple, Anum_pg_database_datcollate, &isnull); + Assert(!isnull); + *dbCollate = TextDatumGetCString(datum); + } if (dbCtype) - *dbCtype = pstrdup(NameStr(dbform->datctype)); + { + datum = SysCacheGetAttr(DATABASEOID, tuple, Anum_pg_database_datctype, &isnull); + Assert(!isnull); + *dbCtype = TextDatumGetCString(datum); + } ReleaseSysCache(tuple); result = true; break; |