Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4ac1742

Browse files
committed
Add new datlastsysoid to pg_database.
This field stores the last allocated OID after the database was created.Used by pg_dump in deciding what is user-defined vs. system-defined.
1 parent7e02371 commit4ac1742

File tree

6 files changed

+35
-16
lines changed

6 files changed

+35
-16
lines changed

‎src/backend/commands/dbcommands.c

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.61 2000/10/16 14:52:03 vadim Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.62 2000/10/22 17:55:36 pjw Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -44,7 +44,6 @@ static bool
4444
get_db_info(constchar*name,char*dbpath,Oid*dbIdP,int4*ownerIdP);
4545

4646

47-
4847
/*
4948
* CREATE DATABASE
5049
*/
@@ -62,7 +61,8 @@ createdb(const char *dbname, const char *dbpath, int encoding)
6261
HeapTupletuple;
6362
TupleDescpg_database_dsc;
6463
Datumnew_record[Natts_pg_database];
65-
charnew_record_nulls[Natts_pg_database]= {' ',' ',' ',' '};
64+
charnew_record_nulls[Natts_pg_database]= {' ',' ',' ',' ',' '};
65+
Oiddboid;
6666

6767
if (!get_user_info(GetUserId(),&use_super,&use_createdb))
6868
elog(ERROR,"current user name is invalid");
@@ -91,6 +91,8 @@ createdb(const char *dbname, const char *dbpath, int encoding)
9191
"The database path '%s' is invalid. "
9292
"This may be due to a character that is not allowed or because the chosen "
9393
"path isn't permitted for databases",dbpath);
94+
#else
95+
locbuf[0]=0;/* Avoid junk in strings */
9496
#endif
9597

9698
/*
@@ -99,16 +101,26 @@ createdb(const char *dbname, const char *dbpath, int encoding)
99101
pg_database_rel=heap_openr(DatabaseRelationName,AccessExclusiveLock);
100102
pg_database_dsc=RelationGetDescr(pg_database_rel);
101103

104+
/*
105+
* Preassign OID for pg_database tuple, so that we know current
106+
* OID counter value
107+
*/
108+
dboid=newoid();
109+
102110
/* Form tuple */
103111
new_record[Anum_pg_database_datname-1]=DirectFunctionCall1(namein,
104112
CStringGetDatum(dbname));
105113
new_record[Anum_pg_database_datdba-1]=Int32GetDatum(GetUserId());
106114
new_record[Anum_pg_database_encoding-1]=Int32GetDatum(encoding);
115+
new_record[Anum_pg_database_datlastsysoid-1]=ObjectIdGetDatum(dboid);/* Save current OID val */
107116
new_record[Anum_pg_database_datpath-1]=DirectFunctionCall1(textin,
108117
CStringGetDatum(locbuf));
109118

110119
tuple=heap_formtuple(pg_database_dsc,new_record,new_record_nulls);
111120

121+
tuple->t_data->t_oid=dboid;/* override heap_insert */
122+
123+
112124
/*
113125
* Update table
114126
*/
@@ -180,6 +192,7 @@ createdb(const char *dbname, const char *dbpath, int encoding)
180192
else
181193
elog(ERROR,"CREATE DATABASE: Could not initialize database directory. Delete failed as well");
182194
}
195+
183196
}
184197

185198

@@ -391,8 +404,6 @@ get_db_info(const char *name, char *dbpath, Oid *dbIdP, int4 *ownerIdP)
391404
returnHeapTupleIsValid(tuple);
392405
}
393406

394-
395-
396407
staticbool
397408
get_user_info(Oiduse_sysid,bool*use_super,bool*use_createdb)
398409
{

‎src/bin/initdb/initdb.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#
2424
# Copyright (c) 1994, Regents of the University of California
2525
#
26-
# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.105 2000/10/16 14:52:21 vadim Exp $
26+
# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.106 2000/10/22 17:55:45 pjw Exp $
2727
#
2828
#-------------------------------------------------------------------------
2929

@@ -597,6 +597,11 @@ cat $TEMPFILE \
597597
|"$PGPATH"/postgres$PGSQL_OPT template1> /dev/null|| exit_nicely
598598
rm -f"$TEMPFILE"|| exit_nicely
599599

600+
echo"Setting lastsysoid."
601+
echo"Update pg_database Set datlastsysoid = (Select max(oid) From pg_description)\
602+
Where datname = 'template1'" \
603+
|"$PGPATH"/postgres$PGSQL_OPT template1> /dev/null|| exit_nicely
604+
600605
echo"Vacuuming database."
601606
echo"VACUUM ANALYZE" \
602607
|"$PGPATH"/postgres$PGSQL_OPT template1> /dev/null|| exit_nicely

‎src/include/catalog/catversion.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
3838
* Portions Copyright (c) 1994, Regents of the University of California
3939
*
40-
* $Id: catversion.h,v 1.50 2000/10/13 00:33:47 pjw Exp $
40+
* $Id: catversion.h,v 1.51 2000/10/22 17:55:49 pjw Exp $
4141
*
4242
*-------------------------------------------------------------------------
4343
*/
@@ -53,6 +53,6 @@
5353
*/
5454

5555
/*yyyymmddN */
56-
#defineCATALOG_VERSION_NO200010131
56+
#defineCATALOG_VERSION_NO200010231
5757

5858
#endif

‎src/include/catalog/pg_attribute.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
99
* Portions Copyright (c) 1994, Regents of the University of California
1010
*
11-
* $Id: pg_attribute.h,v 1.65 2000/10/16 14:52:26 vadim Exp $
11+
* $Id: pg_attribute.h,v 1.66 2000/10/22 17:55:49 pjw Exp $
1212
*
1313
* NOTES
1414
* the genbki.sh script reads this file and generates .bki
@@ -281,7 +281,8 @@ DATA(insert OID = 0 ( 1247 tableoid26 0 4 -7 0 -1 -1 t p f i f f));
281281
DATA(insertOID=0 (1262datname190NAMEDATALEN10-1-1fpfiff));
282282
DATA(insertOID=0 (1262datdba230420-1-1tpfiff));
283283
DATA(insertOID=0 (1262encoding230430-1-1tpfiff));
284-
DATA(insertOID=0 (1262datpath250-140-1-1fxfiff));
284+
DATA(insertOID=0 (1262datlastsysoid260440-1-1tpfiff));
285+
DATA(insertOID=0 (1262datpath250-150-1-1fxfiff));
285286
DATA(insertOID=0 (1262ctid2706-10-1-1fpfiff));
286287
DATA(insertOID=0 (1262oid2604-20-1-1tpfiff));
287288
DATA(insertOID=0 (1262xmin2804-30-1-1tpfiff));

‎src/include/catalog/pg_class.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
99
* Portions Copyright (c) 1994, Regents of the University of California
1010
*
11-
* $Id: pg_class.h,v 1.42 2000/10/16 16:19:14 momjian Exp $
11+
* $Id: pg_class.h,v 1.43 2000/10/22 17:55:49 pjw Exp $
1212
*
1313
* NOTES
1414
* the genbki.sh script reads this file and generates .bki
@@ -142,7 +142,7 @@ DATA(insert OID = 1260 ( pg_shadow 86 PGUID 0 1260 0 0 0 0 f t r 8 0 0 0 0
142142
DESCR("");
143143
DATA(insertOID=1261 (pg_group87PGUID012610000ftr300000fff_null_ ));
144144
DESCR("");
145-
DATA(insertOID=1262 (pg_database88PGUID012620000ftr400000fff_null_ ));
145+
DATA(insertOID=1262 (pg_database88PGUID012620000ftr500000fff_null_ ));
146146
DESCR("");
147147
DATA(insertOID=1264 (pg_variable90PGUID012640000fts100000fff_null_ ));
148148
DESCR("");

‎src/include/catalog/pg_database.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
99
* Portions Copyright (c) 1994, Regents of the University of California
1010
*
11-
* $Id: pg_database.h,v 1.11 2000/10/20 11:01:17 vadim Exp $
11+
* $Id: pg_database.h,v 1.12 2000/10/22 17:55:49 pjw Exp $
1212
*
1313
* NOTES
1414
* the genbki.sh script reads this file and generates .bki
@@ -36,6 +36,7 @@ CATALOG(pg_database) BOOTSTRAP
3636
NameDatadatname;
3737
int4datdba;
3838
int4encoding;
39+
int4datlastsysoid;
3940
textdatpath;/* VARIABLE LENGTH FIELD */
4041
}FormData_pg_database;
4142

@@ -50,13 +51,14 @@ typedef FormData_pg_database *Form_pg_database;
5051
*compiler constants for pg_database
5152
* ----------------
5253
*/
53-
#defineNatts_pg_database4
54+
#defineNatts_pg_database5
5455
#defineAnum_pg_database_datname1
5556
#defineAnum_pg_database_datdba2
5657
#defineAnum_pg_database_encoding3
57-
#defineAnum_pg_database_datpath4
58+
#defineAnum_pg_database_datlastsysoid 4
59+
#defineAnum_pg_database_datpath5
5860

59-
DATA(insertOID=1 (template1PGUIDENCODINGtemplate1 ));
61+
DATA(insertOID=1 (template1PGUIDENCODING0template1 ));
6062
DESCR("");
6163

6264
#defineTemplateDbOid1

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp