PostgreSQL Source Code: src/backend/bootstrap/bootstrap.c Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14

16

18#include <signal.h>

19

41#include "utils/fmgroids.h"

46

47

55

56

57

58

59

60

62

64int numattr;

65

66

67

68

69

70

71

72

73

74

75

89

138

140

146

147static List *Typ = NIL;

149

150

151

152

153

154

155

156

157

158

159

165

185

186

189

191

192

193

194

195

196

197

205

207

208

209

210

211

212

213

214

215static void

220

221

222

223

224

225

226

227

228

229

230

231

232

233void

235{

236 int i;

242

244

246

247

249

250

252 && (strcmp(argv[1], "--boot") == 0

253 || strcmp(argv[1], "--check") == 0));

254 argv++;

255 argc--;

256

257 while ((flag = getopt(argc, argv, "B:c:d:D:Fkr:X:-:")) != -1)

258 {

259 switch (flag)

260 {

261 case 'B':

263 break;

264 case '-':

265

266

267

268

269

270

271

275 errmsg("--%s must be first argument", optarg)));

276

278 case 'c':

279 {

282

285 {

286 if (flag == '-')

289 errmsg("--%s requires a value",

291 else

294 errmsg("-c %s requires a value",

296 }

297

301 break;

302 }

303 case 'D':

305 break;

306 case 'd':

307 {

308

310

317 }

318 break;

319 case 'F':

321 break;

322 case 'k':

324 break;

325 case 'r':

327 break;

328 case 'X':

330 break;

331 default:

332 write_stderr("Try \"%s --help\" for more information.\n",

335 break;

336 }

337 }

338

340 {

343 }

344

345

348

349

350

351

352

355

357

360

362

363

364

365

366

367

369

371

373

374

375

376

377

379

380

381

382

383

384

386 {

390 }

391

392

393

394

396

398

401

402

403

404

405

407 elog(ERROR, "backend is incorrectly linked to frontend functions");

408

410

411

413 {

416 }

417

419 elog(ERROR, "yylex_init() failed: %m");

420

421

422

423

427

428

429

430

431

433

434

437}

438

439

440

441

442

443

444

445

446

447

448static void

450{

452

453

454

455

456

457

462}

463

464

465

466

467

468

469

470

471

472

473

474

475void

477{

478 int i;

479

482

483

484

485

486

489

492

493 elog(DEBUG4, "open relation %s, attrsize %d",

495

499 {

505

506 {

508

509 elog(DEBUG4, "create attribute %d name %s len %d num %d type %u",

510 i, NameStr(at->attname), at->attlen, at->attnum,

511 at->atttypid);

512 }

513 }

514}

515

516

517

518

519

520void

522{

524 {

526 {

528 elog(ERROR, "close of %s when %s was expected",

530 }

531 else

532 elog(ERROR, "close of %s before any relation was opened",

534 }

535

537 elog(ERROR, "no open relation to close");

538 else

539 {

544 }

545}

546

547

548

549

550

551

552

553

554

555

556

557void

559{

560 Oid typeoid;

561

563 {

564 elog(WARNING, "no open relations allowed with CREATE command");

566 }

567

571

575

577

579 {

587

590 else

592 }

593 else

594 {

602

606 else

608 }

609

610

611

612

613

614

615

618

621

623 {

625 }

627 {

629 }

630 else

631 {

633

634

635

636

637

638

640 {

641 int i;

642

643

645 {

648 break;

649 }

652 }

653 }

654}

655

656

657

658

659

660

661

662

663

664void

666{

669 int i;

670

672

675 pfree(tupDesc);

676

680

681

682

683

686}

687

688

689

690

691

692void

694{

696 Oid typoid;

698 bool typbyval;

700 char typdelim;

701 Oid typioparam;

703 Oid typoutput;

704 Oid typcollation;

705

707

709

711 typoid = attr->atttypid;

712

714 &typlen, &typbyval, &typalign,

715 &typdelim, &typioparam,

717 &typcollation);

718

719

720

721

722

723

725 {

726

730 else

731 elog(ERROR, "can't handle pg_node_tree input for %s.%s",

734 }

735 else

736 {

737

739 }

740

741

742

743

744

748}

749

750

751

752

753

754

755

756

757

758

759static void

761{

770

771

773 "pronargs must come before proargdefaults");

775 "pronargdefaults must come before proargdefaults");

777 "proargtypes must come before proargdefaults");

779 elog(ERROR, "pronargs must not be null");

781 elog(ERROR, "proargtypes must not be null");

785

786

793

794

796 elog(ERROR, "too many proargdefaults entries");

797

798

801 {

804 bool typbyval;

806 char typdelim;

807 Oid typioparam;

809 Oid typoutput;

810 Oid typcollation;

814

816 &typlen, &typbyval, &typalign,

817 &typdelim, &typioparam,

819 &typcollation);

820

823 defval = (Datum) 0;

824 else

827 typioparam, -1);

828

830 -1,

831 typcollation,

832 typlen,

833 defval,

835 typbyval);

837 }

838

839

840

841

842

846

847

848

849

850

853}

854

855

856

857

858

859void

861{

862 elog(DEBUG4, "inserting column %d NULL", i);

866 "NULL value specified for not-null column \"%s\" of relation \"%s\"",

871}

872

873

874

875

876

877static void

883

884

885

886

887

888

889

890static void

892{

897

899

904 {

907

910

913 }

917}

918

919

920

921

922

923

924

925

926

927

928

929

930static Oid

932{

934 {

936

938 {

940

942 {

945 }

946 }

947

948

949

950

951

952

956

957

958

959

960

962 {

964

966 {

969 }

970 }

971 }

972 else

973 {

974 int i;

975

977 {

979 return i;

980 }

981

985 }

987

988 return 0;

989}

990

991

992

993

994

995

996

997

998

999

1000

1001

1002void

1005 bool *typbyval,

1007 char *typdelim,

1008 Oid *typioparam,

1010 Oid *typoutput,

1011 Oid *typcollation)

1012{

1014 {

1015

1018

1019 foreach(lc, Typ)

1020 {

1022 if (ap->am_oid == typid)

1023 break;

1024 }

1025

1026 if (ap || ap->am_oid != typid)

1027 elog(ERROR, "type OID %u not found in Typ list", typid);

1028

1029 *typlen = ap->am_typ.typlen;

1030 *typbyval = ap->am_typ.typbyval;

1032 *typdelim = ap->am_typ.typdelim;

1033

1034

1036 *typioparam = ap->am_typ.typelem;

1037 else

1038 *typioparam = typid;

1039

1041 *typoutput = ap->am_typ.typoutput;

1042

1043 *typcollation = ap->am_typ.typcollation;

1044 }

1045 else

1046 {

1047

1049

1051 {

1053 break;

1054 }

1056 elog(ERROR, "type OID %u not found in TypInfo", typid);

1057

1061

1062 *typdelim = ',';

1063

1064

1067 else

1068 *typioparam = typid;

1069

1072

1074 }

1075}

1076

1077

1078

1079

1080

1081

1082

1083

1084

1087{

1089 {

1092 }

1094}

1095

1096

1097

1098

1099

1100

1101

1102

1109

1110

1111

1112

1113

1114

1115

1116

1117

1118

1119

1120

1121void

1125{

1128

1129

1130

1131

1132

1133

1134

1137 "BootstrapNoGC",

1139

1141

1143 newind->il_heap = heap;

1146

1148

1149 newind->il_info->ii_Expressions =

1151 newind->il_info->ii_ExpressionsState = NIL;

1152

1153 newind->il_info->ii_Predicate =

1155 newind->il_info->ii_PredicateState = NULL;

1156

1160

1163

1165}

1166

1167

1168

1169

1170

1171void

1173{

1175 {

1178

1179

1182

1184

1187 }

1188}

#define DatumGetArrayTypeP(X)

void deconstruct_array_builtin(const ArrayType *array, Oid elmtype, Datum **elemsp, bool **nullsp, int *nelemsp)

#define write_stderr(str)

static Oid gettype(char *type)

static Datum values[MAXATTR]

void closerel(char *relname)

static void populate_typ_list(void)

static void CheckerModeMain(void)

void InsertOneValue(char *value, int i)

static void cleanup(void)

void InsertOneNull(int i)

static const struct rolinfo RolInfo[]

static const struct typinfo TypInfo[]

static struct typmap * Ap

void InsertOneTuple(void)

void boot_get_type_io_data(Oid typid, int16 *typlen, bool *typbyval, char *typalign, char *typdelim, Oid *typioparam, Oid *typinput, Oid *typoutput, Oid *typcollation)

static void InsertOneProargdefaultsValue(char *value)

struct _IndexList IndexList

static void bootstrap_signals(void)

Form_pg_attribute attrtypes[MAXATTR]

Oid boot_get_role_oid(const char *rolname)

static Form_pg_attribute AllocateAttribute(void)

static MemoryContext nogc

void BootstrapModeMain(int argc, char *argv[], bool check_only)

void DefineAttr(char *name, char *type, int attnum, int nullness)

static bool Nulls[MAXATTR]

void index_register(Oid heap, Oid ind, const IndexInfo *indexInfo)

void boot_openrel(char *relname)

static IndexList * ILHead

#define BOOTCOL_NULL_FORCE_NULL

int boot_yylex_init(yyscan_t *yyscannerp)

#define BOOTCOL_NULL_FORCE_NOT_NULL

#define BOOTCOL_NULL_AUTO

int boot_yyparse(yyscan_t yyscanner)

#define PG_DATA_CHECKSUM_VERSION

#define CStringGetTextDatum(s)

#define Assert(condition)

#define MemSet(start, val, len)

#define StaticAssertDecl(condition, errmessage)

#define OidIsValid(objectId)

int errcode(int sqlerrcode)

int int errmsg_internal(const char *fmt,...) pg_attribute_printf(1

#define ereport(elevel,...)

void set_max_safe_fds(void)

#define palloc_object(type)

Datum OidInputFunctionCall(Oid functionId, char *str, Oid typioparam, int32 typmod)

char * OidOutputFunctionCall(Oid functionId, Datum val)

#define OidFunctionCall3(functionId, arg1, arg2, arg3)

char OutputFileName[MAXPGPATH]

void SetConfigOption(const char *name, const char *value, GucContext context, GucSource source)

bool SelectConfigFiles(const char *userDoption, const char *progname)

void ParseLongOption(const char *string, char **name, char **value)

void InitializeGUCOptions(void)

HeapTuple heap_getnext(TableScanDesc sscan, ScanDirection direction)

void simple_heap_insert(Relation relation, HeapTuple tup)

HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, const Datum *values, const bool *isnull)

void heap_freetuple(HeapTuple htup)

static void * GETSTRUCT(const HeapTupleData *tuple)

void index_build(Relation heapRelation, Relation indexRelation, IndexInfo *indexInfo, bool isreindex, bool parallel)

void index_close(Relation relation, LOCKMODE lockmode)

Relation index_open(Oid relationId, LOCKMODE lockmode)

void CreateSharedMemoryAndSemaphores(void)

bool pg_link_canary_is_frontend(void)

List * lappend(List *list, void *datum)

void list_free_deep(List *list)

DispatchOption parse_dispatch_option(const char *name)

RangeVar * makeRangeVar(char *schemaname, char *relname, int location)

Const * makeConst(Oid consttype, int32 consttypmod, Oid constcollid, int constlen, Datum constvalue, bool constisnull, bool constbyval)

void * MemoryContextAllocZero(MemoryContext context, Size size)

char * pstrdup(const char *in)

void pfree(void *pointer)

MemoryContext TopMemoryContext

#define AllocSetContextCreate

#define ALLOCSET_DEFAULT_SIZES

#define SetProcessingMode(mode)

void ChangeToDataDir(void)

void InitStandaloneProcess(const char *argv0)

void CreateDataDirLockFile(bool amPostmaster)

void namestrcpy(Name name, const char *str)

char * nodeToString(const void *obj)

static MemoryContext MemoryContextSwitchTo(MemoryContext context)

#define ATTRIBUTE_FIXED_PART_SIZE

FormData_pg_attribute * Form_pg_attribute

int getopt(int nargc, char *const *nargv, const char *ostr)

PGDLLIMPORT char * optarg

END_CATALOG_STRUCT typedef FormData_pg_type * Form_pg_type

void InitPostmasterChildSlots(void)

size_t strlcpy(char *dst, const char *src, size_t siz)

static const char * userDoption

static Datum PointerGetDatum(const void *X)

static Datum Int16GetDatum(int16 X)

static Datum ObjectIdGetDatum(Oid X)

static char * DatumGetCString(Datum X)

static Pointer DatumGetPointer(Datum X)

static Datum CStringGetDatum(const char *X)

static Datum Int32GetDatum(int32 X)

static int16 DatumGetInt16(Datum X)

void InitializeMaxBackends(void)

void InitializeFastPathLocks(void)

void InitPostgres(const char *in_dbname, Oid dboid, const char *username, Oid useroid, bits32 flags, char *out_dbname)

char * psprintf(const char *fmt,...)

#define RelationGetRelid(relation)

#define RelationGetDescr(relation)

#define RelationGetNumberOfAttributes(relation)

#define RelationGetRelationName(relation)

void RelationMapFinishBootstrap(void)

uint16 * ii_ExclusionStrats

struct _IndexList * il_next

void table_close(Relation relation, LOCKMODE lockmode)

Relation table_open(Oid relationId, LOCKMODE lockmode)

Relation table_openrv(const RangeVar *relation, LOCKMODE lockmode)

TableScanDesc table_beginscan_catalog(Relation relation, int nkeys, ScanKeyData *key)

static void table_endscan(TableScanDesc scan)

#define InvalidCompressionMethod

TupleDesc CreateTupleDesc(int natts, Form_pg_attribute *attrs)

static FormData_pg_attribute * TupleDescAttr(TupleDesc tupdesc, int i)

void StartTransactionCommand(void)

void CommitTransactionCommand(void)

void BootStrapXLOG(uint32 data_checksum_version)