Skip to content

Commit dc8156e

Browse files
committed
Tidy up of commented out code and remove debug print statements
1 parent fb0ddfb commit dc8156e

File tree

15 files changed

+162
-140
lines changed

15 files changed

+162
-140
lines changed

src/backend/access/transam/slru.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1557,8 +1557,6 @@ SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data)
15571557
int segno;
15581558
int segpage;
15591559

1560-
elog(LOG, "! SlruScanDirectory start %s, %s", getcwd(NULL, 100), ctl->Dir);
1561-
15621560
cldir = AllocateDir(ctl->Dir);
15631561
while ((clde = ReadDir(cldir, ctl->Dir)) != NULL)
15641562
{
@@ -1572,7 +1570,7 @@ SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data)
15721570
segno = (int) strtol(clde->d_name, NULL, 16);
15731571
segpage = segno * SLRU_PAGES_PER_SEGMENT;
15741572

1575-
elog(LOG, "SlruScanDirectory invoking callback on %s/%s",
1573+
elog(DEBUG2, "SlruScanDirectory invoking callback on %s/%s",
15761574
ctl->Dir, clde->d_name);
15771575
retval = callback(ctl, clde->d_name, segpage, data);
15781576
if (retval)
@@ -1581,8 +1579,6 @@ SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data)
15811579
}
15821580
FreeDir(cldir);
15831581

1584-
elog(LOG, "! SlruScanDirectory stop");
1585-
15861582
return retval;
15871583
}
15881584

src/backend/main/main.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ main(int argc, char *argv[])
6363
{
6464
bool do_check_root = true;
6565

66-
printf("Hey-hey!\n");
67-
6866
/*
6967
* If supported on the current platform, set up a handler to be called if
7068
* the backend/postmaster crashes with a fatal signal or exception.

src/backend/nodes/nodeFuncs.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4000,32 +4000,24 @@ planstate_tree_walker(PlanState *planstate,
40004000
/* Guard against stack overflow due to overly complex plan trees */
40014001
check_stack_depth();
40024002

4003-
// printf("planstate_tree_walker1\n");
4004-
40054003
/* initPlan-s */
40064004
if (planstate_walk_subplans(planstate->initPlan, walker, context))
40074005
return true;
40084006

4009-
// printf("planstate_tree_walker2\n");
4010-
40114007
/* lefttree */
40124008
if (outerPlanState(planstate))
40134009
{
40144010
if (walker(outerPlanState(planstate), context))
40154011
return true;
40164012
}
40174013

4018-
// printf("planstate_tree_walker3\n");
4019-
40204014
/* righttree */
40214015
if (innerPlanState(planstate))
40224016
{
40234017
if (walker(innerPlanState(planstate), context))
40244018
return true;
40254019
}
40264020

4027-
// printf("planstate_tree_walker4\n");
4028-
40294021
/* special child plans */
40304022
switch (nodeTag(plan))
40314023
{

src/backend/port/sysv_shmem.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ PGSharedMemoryCreate(Size size,
657657
struct stat statbuf;
658658
Size sysvsize;
659659

660-
elog(NOTICE, "! Hacky way to init shared memory");
660+
elog(NOTICE, "Init WASM shared memory");
661661

662662
/* Initialize new segment. */
663663
hdr = (PGShmemHeader *) malloc(size);
@@ -691,9 +691,6 @@ PGSharedMemoryCreate(Size size,
691691
memcpy(AnonymousShmem, hdr, sizeof(PGShmemHeader));
692692
return (PGShmemHeader *) AnonymousShmem;
693693

694-
695-
696-
697694
/*
698695
* We use the data directory's ID info (inode and device numbers) to
699696
* positively identify shmem segments associated with this data dir, and

src/backend/postmaster/postmaster.c

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1501,22 +1501,24 @@ getInstallationPaths(const char *argv0)
15011501
*/
15021502
get_pkglib_path(my_exec_path, pkglib_path);
15031503

1504-
// /*
1505-
// * Verify that there's a readable directory there; otherwise the Postgres
1506-
// * installation is incomplete or corrupt. (A typical cause of this
1507-
// * failure is that the postgres executable has been moved or hardlinked to
1508-
// * some directory that's not a sibling of the installation lib/
1509-
// * directory.)
1510-
// */
1511-
// pdir = AllocateDir(pkglib_path);
1512-
// if (pdir == NULL)
1513-
// ereport(ERROR,
1514-
// (errcode_for_file_access(),
1515-
// errmsg("could not open directory \"%s\": %m",
1516-
// pkglib_path),
1517-
// errhint("This may indicate an incomplete PostgreSQL installation, or that the file \"%s\" has been moved away from its proper location.",
1518-
// my_exec_path)));
1519-
// FreeDir(pdir);
1504+
#ifndef EMSCRIPTEN
1505+
/*
1506+
* Verify that there's a readable directory there; otherwise the Postgres
1507+
* installation is incomplete or corrupt. (A typical cause of this
1508+
* failure is that the postgres executable has been moved or hardlinked to
1509+
* some directory that's not a sibling of the installation lib/
1510+
* directory.)
1511+
*/
1512+
pdir = AllocateDir(pkglib_path);
1513+
if (pdir == NULL)
1514+
ereport(ERROR,
1515+
(errcode_for_file_access(),
1516+
errmsg("could not open directory \"%s\": %m",
1517+
pkglib_path),
1518+
errhint("This may indicate an incomplete PostgreSQL installation, or that the file \"%s\" has been moved away from its proper location.",
1519+
my_exec_path)));
1520+
FreeDir(pdir);
1521+
#endif
15201522

15211523
/*
15221524
* XXX is it worth similarly checking the share/ directory? If the lib/

src/backend/storage/smgr/md.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -746,9 +746,6 @@ mdwrite(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
746746
errhint("Check free disk space.")));
747747
}
748748

749-
// printf("! writing block %u in file \"%s\"\n",
750-
// blocknum, FilePathName(v->mdfd_vfd));
751-
752749
if (!skipFsync && !SmgrIsTemp(reln))
753750
register_dirty_segment(reln, forknum, v);
754751
}

src/backend/tcop/postgres.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -315,8 +315,6 @@ InteractiveBackend(StringInfo inBuf)
315315
* Even though we are not reading from a "client" process, we still want to
316316
* respond to signals, particularly SIGTERM/SIGQUIT.
317317
*/
318-
// FILE *query_in = NULL;
319-
320318
static int
321319
interactive_getc(void)
322320
{
@@ -330,11 +328,6 @@ interactive_getc(void)
330328
*/
331329
CHECK_FOR_INTERRUPTS();
332330

333-
// if (!query_in) {
334-
// printf("Reading query now\n");
335-
// query_in = fopen("/Users/stas/datadir/q.sql","r");
336-
// }
337-
338331
c = getc(stdin);
339332

340333
ProcessClientReadInterrupt(false);

src/backend/utils/init/miscinit.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -337,14 +337,14 @@ checkDataDir(void)
337337
*
338338
* XXX can we safely enable this check on Windows?
339339
*/
340-
// #if !defined(WIN32) && !defined(__CYGWIN__)
341-
// if (stat_buf.st_uid != geteuid())
342-
// ereport(FATAL,
343-
// (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
344-
// errmsg("data directory \"%s\" has wrong ownership",
345-
// DataDir),
346-
// errhint("The server must be started by the user that owns the data directory.")));
347-
// #endif
340+
#if !defined(WIN32) && !defined(__CYGWIN__) && !defined(EMSCRIPTEN)
341+
if (stat_buf.st_uid != geteuid())
342+
ereport(FATAL,
343+
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
344+
errmsg("data directory \"%s\" has wrong ownership",
345+
DataDir),
346+
errhint("The server must be started by the user that owns the data directory.")));
347+
#endif
348348

349349
/*
350350
* Check if the directory has correct permissions. If not, reject.
@@ -357,14 +357,14 @@ checkDataDir(void)
357357
* be proper support for Unix-y file permissions. Need to think of a
358358
* reasonable check to apply on Windows.
359359
*/
360-
// #if !defined(WIN32) && !defined(__CYGWIN__)
361-
// if (stat_buf.st_mode & PG_MODE_MASK_GROUP)
362-
// ereport(FATAL,
363-
// (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
364-
// errmsg("data directory \"%s\" has invalid permissions",
365-
// DataDir),
366-
// errdetail("Permissions should be u=rwx (0700) or u=rwx,g=rx (0750).")));
367-
// #endif
360+
#if !defined(WIN32) && !defined(__CYGWIN__) && !defined(EMSCRIPTEN)
361+
if (stat_buf.st_mode & PG_MODE_MASK_GROUP)
362+
ereport(FATAL,
363+
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
364+
errmsg("data directory \"%s\" has invalid permissions",
365+
DataDir),
366+
errdetail("Permissions should be u=rwx (0700) or u=rwx,g=rx (0750).")));
367+
#endif
368368

369369
/*
370370
* Reset creation modes and mask based on the mode of the data directory.

src/backend/utils/misc/ps_status.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
#include <machine/vmparam.h> /* for old BSD */
2323
#include <sys/exec.h>
2424
#endif
25-
// #if defined(__darwin__)
26-
// #include <crt_externs.h>
27-
// #endif
25+
#if defined(__darwin__) && !defined(EMSCRIPTEN)
26+
#include <crt_externs.h>
27+
#endif
2828

2929
#include "libpq/libpq.h"
3030
#include "miscadmin.h"
@@ -230,14 +230,14 @@ save_ps_display_args(int argc, char **argv)
230230
}
231231
new_argv[argc] = NULL;
232232

233-
// #if defined(__darwin__)
233+
#if defined(__darwin__) && !defined(EMSCRIPTEN)
234234

235-
// /*
236-
// * macOS (and perhaps other NeXT-derived platforms?) has a static copy
237-
// * of the argv pointer, which we may fix like so:
238-
// */
239-
// *_NSGetArgv() = new_argv;
240-
// #endif
235+
/*
236+
* macOS (and perhaps other NeXT-derived platforms?) has a static copy
237+
* of the argv pointer, which we may fix like so:
238+
*/
239+
*_NSGetArgv() = new_argv;
240+
#endif
241241

242242
argv = new_argv;
243243
}

src/bin/psql/command.c

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -553,20 +553,22 @@ exec_command_cd(PsqlScanState scan_state, bool active_branch, const char *cmd)
553553
dir = opt;
554554
else
555555
{
556-
#ifndef WIN32
556+
#if defined(EMSCRIPTEN)
557+
dir = "/";
558+
#elif !defined(WIN32)
557559
struct passwd *pw;
558560
uid_t user_id = geteuid();
559561

560-
// errno = 0; /* clear errno before call */
561-
// pw = getpwuid(user_id);
562-
// if (!pw)
563-
// {
564-
// pg_log_error("could not get home directory for user ID %ld: %s",
565-
// (long) user_id,
566-
// errno ? strerror(errno) : _("user does not exist"));
567-
// exit(EXIT_FAILURE);
568-
// }
569-
dir = "/Users/stas/datadir";
562+
errno = 0; /* clear errno before call */
563+
pw = getpwuid(user_id);
564+
if (!pw)
565+
{
566+
pg_log_error("could not get home directory for user ID %ld: %s",
567+
(long) user_id,
568+
errno ? strerror(errno) : _("user does not exist"));
569+
exit(EXIT_FAILURE);
570+
}
571+
dir = pw->pw_dir;
570572
#else /* WIN32 */
571573

572574
/*

0 commit comments

Comments
 (0)