bugphpGroupWare - Bugs: bug #5628, Setup does not create db

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #5628: Setup does not create db

Submitted by:  Johnson <jecinc>
Submitted on:  Tue 30 Sep 2003 03:30:26 AM UTC  
 
Item Group: 0.9.16RC1Category: API - Setup
Severity: 3 - NormalPriority: 5 - Normal
Status: FixedPrivacy: Public
Assigned to: Dave Hall <skwashd>Open/Closed: Closed
Component Version: SVNOperating System: GNU/Linux - RedHat/Fedora
Reproducibility: NonePlanned Release: None
Fixed Release: 

(Jump to the original submission Jump to the original submission)

Thu 09 Oct 2003 02:16:55 PM UTC, comment #7:

I'm not sure what you want, there are two patches for the same information posted here as separate entries. One against the original file, and one against cvs

Johnson <jecinc>
Thu 09 Oct 2003 01:31:22 PM UTC, comment #6:

what's the difference? a diff is a diff, cvs uses diff too, so doing a diff on CVS and a diff on a file saved from cvs will produce the same results. Though i do agree that the patchmanager should be used instead of spamming it in to the bug report, which could be the problem.

Chris Weiss <cw>
Project Administrator
Thu 09 Oct 2003 08:31:00 AM UTC, comment #5:

Tried appling the patch ... it is fux0r ... please submit it via the patch manager using diff not cvs diff

Dave Hall <skwashd>
Project AdministratorIn charge of this item.
Wed 08 Oct 2003 07:20:27 PM UTC, comment #4:

Dave can you see that this get's commited?

Chris Weiss <cw>
Project Administrator
Fri 03 Oct 2003 04:15:36 PM UTC, comment #3:

another try

cvs -z6 diff -u class.db_pgsql.inc.php

Index: class.db_pgsql.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/phpgwapi/inc/class.db_pgsql.inc.php,v
retrieving revision 1.30.2.1.2.4
diff -u -r1.30.2.1.2.4 class.db_pgsql.inc.php
--- class.db_pgsql.inc.php 8 Sep 2003 01:27:44 -0000 1.30.2.1.2.4
+++ class.db_pgsql.inc.php 3 Oct 2003 16:14:10 -0000
@@ -56,7 +56,6 @@
{
$Password = $this->Password;
}
-
if (! $this->Link_ID)
{
$cstr = 'dbname=' . $Database
@@ -66,27 +65,28 @@
. $this->ifadd("'".$Password."'", 'password=');
if ($GLOBALS['phpgw_info']['server']['db_persistent'])
{
- $this->Link_ID=pg_pconnect($cstr);
+ $this->Link_ID=@pg_pconnect($cstr);
}
else
{
- $this->Link_ID=pg_connect($cstr);
+ $this->Link_ID=@pg_connect($cstr);
}

if (! $this->Link_ID)
{
- $this->halt('Link-ID == false, '.($GLOBALS['phpgw_info']['server']['db_persistent']?'p':'').'connect failed');
+ $this->halt(($GLOBALS['phpgw_info']['server']['db_persistent']?'p':'')."connect($Host, $User, \$Password) failed.");
+ return 0;
}
else
{
$this->query("select version()",__LINE__,__FILE__);
$this->next_record();
-
$version = $this->f('version');
$parts = explode(' ',$version);
$this->db_version = $parts[1];
}
}
+ return $this->Link_ID;
}

function to_timestamp($epoch)
@@ -147,6 +147,7 @@
return @pg_close($this->Link_ID);
}

+
function query($Query_String, $line = '', $file = '')
{
if ($Query_String == '')
@@ -154,20 +155,33 @@
return 0;
}

- $this->connect();
-
- /* printf("<br>Debug: query = %s<br>\n", $Query_String); */
+ if (!$this->connect())
+ {
+ return 0; /* we already complained in connect() about that. */
+ };
+ # New query, discard previous result.
+ if ($this->Query_ID)
+ {
+ $this->free();
+ }
+

+ if ($this->Debug)
+ {
+ printf("Debug: query = %s<br>\n", $Query_String);
+ }

$this->Query_ID = @pg_Exec($this->Link_ID, $Query_String);
$this->Row = 0;

- $this->Error = pg_ErrorMessage($this->Link_ID);
+ $this->Error = @pg_ErrorMessage($this->Link_ID);
$this->Errno = ($this->Error == '') ? 0 : 1;
if (! $this->Query_ID)
{
+ return 0;
$this->halt('Invalid SQL: ' . $Query_String, $line, $file);
}

+ # Will return nada if it fails. That's fine.
return $this->Query_ID;
}

@@ -205,8 +219,11 @@
{
$this->Record = @pg_fetch_array($this->Query_ID, $this->Row++);

- $this->Error = pg_ErrorMessage($this->Link_ID);
- $this->Errno = ($this->Error == '') ? 0 : 1;
+ if ($this->Link_ID)
+ {
+ $this->Error = pg_ErrorMessage($this->Link_ID);
+ $this->Errno = ($this->Error == '') ? 0 : 1;
+ }

$stat = is_array($this->Record);
if (!$stat && $this->Auto_Free)
@@ -241,7 +258,7 @@

function transaction_abort()
{
- return pg_Exec($this->Link_ID,'rollback');
+ return @pg_Exec($this->Link_ID,'rollback');
}

function get_last_insert_id($table, $field)
@@ -392,17 +409,19 @@
return pg_numfields($this->Query_ID);
}

+ /* private: error handling */
function halt($msg, $line = '', $file = '')
{
+ $this->Error = @pg_ErrorMessage($this->Link_ID);
+ $this->Errno = 1;
+

if ($this->Halt_On_Error == 'no')
{
return;
}
-
/* Just in case there is a table currently locked */
$this->transaction_abort();

-
if ($this->xmlrpc || $this->soap)
{
$s = sprintf("Database error: %s\n", $msg);
@@ -500,8 +519,13 @@
{
$this->User = $adminname;
$this->Password = $adminpasswd;
+ $this->Database = "template1";
}

+ /*
+ This doesn't work if the httpd server user doesn't have execute permissions on the createdb program
+ */
+ /*
if (! $this->Host)
{
system('createdb ' . $currentDatabase, $outval);
@@ -510,13 +534,16 @@
{
system('createdb -h ' . $this->Host . ' ' . $currentDatabase, $outval);
}
-
if($outval != 0)
{
- /* either the rights r not available or the postmaster is not running .... */
+ // either the rights r not available or the postmaster is not running ....
echo 'database creation failure <BR>';
echo 'please setup the postreSQL database manually<BR>';
}
+ */
+
+ $this->query("CREATE DATABASE $currentDatabase");
+ $this->query("grant all on $currentDatabase.* to $currentUser@localhost identified by
'$currentPassword'");

$this->User = $currentUser;
$this->Password = $currentPassword;

Johnson <jecinc>
Fri 03 Oct 2003 03:48:58 PM UTC, comment #2:

Here is patch (diff phpgwapi/inc/class.db_pgsql.inc.php phpgwapi/inc/class.db_pgsql.inc.php.orig):

58a59

>

68c69
< $this->Link_ID=@pg_pconnect($cstr);
---

> $this->Link_ID=pg_pconnect($cstr);

72c73
< $this->Link_ID=@pg_connect($cstr);
---

> $this->Link_ID=pg_connect($cstr);

77,78c78
< $this->halt(($GLOBALS['phpgw_info']['server']['db_persistent']?'p':'')."connect($Host, $User, \$Password) failed.");
< return 0;
---

> $this->halt('Link-ID == false, '.($GLOBALS['phpgw_info']['server']['db_persistent']?'p':'').'connect failed');

83a84

>

89d89
< return $this->Link_ID;
150d149
<
158,171c157,159
< if (!$this->connect())
< {
< return 0; /* we already complained in connect() about that. */
< };
< # New query, discard previous result.
< if ($this->Query_ID)
< {
< $this->free();
< }
<

< if ($this->Debug)
< {
< printf("Debug: query = %s<br>\n", $Query_String);
< }
---

> $this->connect();
>
> /* printf("<br>Debug: query = %s<br>\n", $Query_String); */

176c164
< $this->Error = @pg_ErrorMessage($this->Link_ID);
---

> $this->Error = pg_ErrorMessage($this->Link_ID);

180d167
< return 0;
184d170
< # Will return nada if it fails. That's fine.
222,226c208,209
< if ($this->Link_ID)
< {
< $this->Error = pg_ErrorMessage($this->Link_ID);
< $this->Errno = ($this->Error == '') ? 0 : 1;
< }
---

> $this->Error = pg_ErrorMessage($this->Link_ID);
> $this->Errno = ($this->Error == '') ? 0 : 1;

261c244
< return @pg_Exec($this->Link_ID,'rollback');
---

> return pg_Exec($this->Link_ID,'rollback');

412d394
< /* private: error handling */
415,417d396
< $this->Error = @pg_ErrorMessage($this->Link_ID);
< $this->Errno = 1;
<

421a401

>

424a405

>

522d502
< $this->Database = "template1";
525,528d504
< /*
< This doesn't work if the httpd server user doesn't have execute permissions on the createdb program
< */
< /*
536a513

>

539c516
< // either the rights r not available or the postmaster is not running ....
---

> /* either the rights r not available or the postmaster is not running .... */

543,546d519
< */
<
< $this->query("CREATE DATABASE $currentDatabase");
< $this->query("grant all on $currentDatabase.* to $currentUser@localhost identified by '$currentPassword'");

Johnson <jecinc>
Tue 30 Sep 2003 09:18:53 PM UTC, comment #1:

um, yeah, I added/fixed this for mysql, but I don't have a pgsql install (and don't plan on learning it anytime soon). Can someone port teh mysql functions to pg?

Chris Weiss <cw>
Project Administrator
Tue 30 Sep 2003 03:30:26 AM UTC, original submission:

It is my understanding that the setup app is to create the db if it doesn't exist (after the header file is made).

When I log into setup I get:
Warning: pg_pconnect() PostgreSQL link lost, unable to reconnect in /home/htdocs/phpgroupwaretest16/phpgwapi/inc/class.db_pgsql.inc.php on line 69

Warning: pg_errormessage(): supplied argument is not a valid PostgreSQL link resource in /home/htdocs/phpgroupwaretest16/phpgwapi/inc/class.db_pgsql.inc.php on line 164

Warning: pg_errormessage(): supplied argument is not a valid PostgreSQL link resource in /home/htdocs/phpgroupwaretest16/phpgwapi/inc/class.db_pgsql.inc.php on line 208

Warning: pg_pconnect() unable to connect to PostgreSQL server: FATAL 1: Database "phpgroupwaretest16" does not exist in the system catalog. in /home/htdocs/phpgroupwaretest16/phpgwapi/inc/class.db_pgsql.inc.php on line 69

Warning: pg_errormessage(): supplied argument is not a valid PostgreSQL link resource in /home/htdocs/phpgroupwaretest16/phpgwapi/inc/class.db_pgsql.inc.php on line 164

Warning: pg_pconnect() unable to connect to PostgreSQL server: FATAL 1: Database "phpgroupwaretest16" does not exist in the system catalog. in /home/htdocs/phpgroupwaretest16/phpgwapi/inc/class.db_pgsql.inc.php on line 69

Warning: pg_errormessage(): supplied argument is not a valid PostgreSQL link resource in /home/htdocs/phpgroupwaretest16/phpgwapi/inc/class.db_pgsql.inc.php on line 164

Warning: pg_pconnect() unable to connect to PostgreSQL server: FATAL 1: Database "phpgroupwaretest16" does not exist in the system catalog. in /home/htdocs/phpgroupwaretest16/phpgwapi/inc/class.db_pgsql.inc.php on line 69

Warning: pg_errormessage(): supplied argument is not a valid PostgreSQL link resource in /home/htdocs/phpgroupwaretest16/phpgwapi/inc/class.db_pgsql.inc.php on line 164

Warning: pg_errormessage(): supplied argument is not a valid PostgreSQL link resource in /home/htdocs/phpgroupwaretest16/phpgwapi/inc/class.db_pgsql.inc.php on line 208

Warning: pg_pconnect() unable to connect to PostgreSQL server: FATAL 1: Database "phpgroupwaretest16" does not exist in the system catalog. in /home/htdocs/phpgroupwaretest16/phpgwapi/inc/class.db_pgsql.inc.php on line 69

Warning: pg_errormessage(): supplied argument is not a valid PostgreSQL link resource in /home/htdocs/phpgroupwaretest16/phpgwapi/inc/class.db_pgsql.inc.php on line 164

Warning: pg_errormessage(): supplied argument is not a valid PostgreSQL link resource in /home/htdocs/phpgroupwaretest16/phpgwapi/inc/class.db_pgsql.inc.php on line 208

Warning: pg_pconnect() unable to connect to PostgreSQL server: FATAL 1: Database "phpgroupwaretest16" does not exist in the system catalog. in /home/htdocs/phpgroupwaretest16/phpgwapi/inc/class.db_pgsql.inc.php on line 69

Warning: pg_errormessage(): supplied argument is not a valid PostgreSQL link resource in /home/htdocs/phpgroupwaretest16/phpgwapi/inc/class.db_pgsql.inc.php on line 164

Warning: pg_pconnect() unable to connect to PostgreSQL server: FATAL 1: Database "phpgroupwaretest16" does not exist in the system catalog. in /home/htdocs/phpgroupwaretest16/phpgwapi/inc/class.db_pgsql.inc.php on line 69

Warning: pg_errormessage(): supplied argument is not a valid PostgreSQL link resource in /home/htdocs/phpgroupwaretest16/phpgwapi/inc/class.db_pgsql.inc.php on line 164

Johnson <jecinc>

 

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

Do you think this task is very important?
If so, you can click here to add your encouragement to it.
This task has 0 encouragements so far.

Only logged-in users can vote.

 

Please enter the title of George Orwell's famous dystopian book (it's a date):

 

 

Follow 4 latest changes.

Date Changed By Updated Field Previous Value => Replaced By
Fri 10 Oct 2003 05:49:20 AM UTCskwashdPriority100(Error - Not Found)=>(Error - Not Found)
  StatusNone=>(Error - Not Found)
  Open/ClosedOpen=>(Error - Not Found)
Wed 08 Oct 2003 07:20:24 PM UTCcwAssigned tocw=>NA

Back to the top


Powered by Savane 3.1-cleanup1