[GENERAL] Re: [HACKERS] random() function produces wrong range

2000-08-03 Thread Roland Roberts

-BEGIN PGP SIGNED MESSAGE-

> "Thomas" == Thomas Swan <[EMAIL PROTECTED]> writes:

Thomas> Is it possible to test (during configure phase) and then
Thomas> go from there...  or does it need to be the same for all
Thomas> platforms?

You should be able to test, but it is, of course, a statistical test.
Call random() several times and test the maximum value against your
thresholds of 2^15 and 2^31.  If random() is generating values in the
range 1:2^31-1, you would expect half of your values to be greater
than 2^15-1; more importantly, if you generate, say, 10 values, you
expect only a 1:1024 chance that they are all below 2^15.  If those
odds aren't good enough, generate more.

roland
- -- 
   PGP Key ID: 66 BC 3B CD
Roland B. Roberts, PhDUnix Software Solutions
[EMAIL PROTECTED]  76-15 113th Street, Apt 3B
[EMAIL PROTECTED]  Forest Hills, NY 11375

-BEGIN PGP SIGNATURE-
Version: 2.6.3a
Charset: noconv
Comment: Processed by Mailcrypt 3.5.4, an Emacs/PGP interface

iQCVAwUBOYmNSeoW38lmvDvNAQHFegQAlexEvaG0t+1H0IkPWikbdMUIck1fE0DI
rfcGi1M/SQ6K9Hmvi1HB/SVEU4DKGaHDoqlU7ei78OgOzchbsLL5cqAJNIsKv5QJ
F4u/A0Fg7yuyRZ3/CNCo0+nTwhyDANktMw78AM5ssHCs75UxC+vHWibHHBmXJzrF
8WD2LyjPSNI=
=dR25
-END PGP SIGNATURE-



Re: [GENERAL] Re: [HACKERS] random() function produces wrong range

2000-08-03 Thread Roland Roberts

-BEGIN PGP SIGNED MESSAGE-

> "Tom" == Tom Lane <[EMAIL PROTECTED]> writes:

Tom> Actually the odds are far better than that.  If the range is
Tom> 2^31-1 then only about 2^-16th of the outputs should be less
Tom> than 2^15.  So ten probes gives you a failure probability of
Tom> about 2^-160 not 2^-10.

Oops, 2^16 != 2^32 / 2.

So a dynamic test is not only possible but wouldn't cost to much at
configure time.

roland
- -- 
   PGP Key ID: 66 BC 3B CD
Roland B. Roberts, PhDUnix Software Solutions
[EMAIL PROTECTED]  76-15 113th Street, Apt 3B
[EMAIL PROTECTED]  Forest Hills, NY 11375

-BEGIN PGP SIGNATURE-
Version: 2.6.3a
Charset: noconv
Comment: Processed by Mailcrypt 3.5.4, an Emacs/PGP interface

iQCVAwUBOYmtf+oW38lmvDvNAQGWYwP/eXRtrDPu/xN+W9pCd9y34d4jbrPH7jku
nBAuSYtCRyoMgTkjdCtqThzq3vzPLDwfmOZcmWP8W5AmQPJjvcdFwI7y1XgGlaxd
aAIlqqf+TTkZwIUh2vnWTuu5JKkiAZI6UuzNSzy79O/frxKE2y97zCuMw02I0kMK
iGNSybN3L5w=
=36yP
-END PGP SIGNATURE-



[GENERAL] Re: [SQL] Permissons on database

2001-03-12 Thread Roland Roberts

> "bk" == Boulat Khakimov <[EMAIL PROTECTED]> writes:

bk> How do I grant permissions on everything in the selected
bk> databes?

bk> GRANT doesnt take as on object database name nor does it
bk> accept wild chars

Attached is some Perl code I wrote long ago to do this.  This
particular code was done for Keystone, a problem tracking database and
it would do a "GRANT ALL".  Modify it as needed.  Last I checked it
worked with both PostgreSQL 6.5.x and 7.0.x



#! /usr/bin/perl -w
# I'm also appending a Perl script to grant public access to all
# keystone tables.  It uses the Pg module for PostgreSQL, so you will
# need to add that first.  However, I find it a bit less tedious than
# granting access by hand
# Roland B. Roberts, PhD  Custom Software Solutions
# [EMAIL PROTECTED]   101 West 15th St #4NN
# [EMAIL PROTECTED]  New York, NY 10011

use Pg;

if (defined $ARGV[0]) {
$dbname = $ARGV[0];
} else {
$dbname = "keystone";
}
print "connecting to $dbname\n";
$dbh = Pg::connectdb("dbname=$dbname $ARGV[1]");
die "Pg::connectdb failed, $dbh->errorMessage"
unless ($dbh->status == PGRES_CONNECTION_OK);

$c{relname} = $dbh->exec ("select relname from pg_class where relname !~ '^pg_'  and 
relkind != 'i'");

die "Pg::exec, $dbh->errorMessage" 
unless ($c{relname}->resultStatus == PGRES_TUPLES_OK);

for ($i = 0; $i < $c{relname}->ntuples; $i++) {
$relname = $c{relname}->getvalue($i,0);
print "grant all on $relname to public\n";
$c{grant} = $dbh->exec ("grant all on $relname to public");
die "Pg::exec, ".$dbh->errorMessage
unless ($c{grant}->resultStatus == PGRES_COMMAND_OK);
}



roland
-- 
   PGP Key ID: 66 BC 3B CD
Roland B. Roberts, PhD RL Enterprises
[EMAIL PROTECTED] 76-15 113th Street, Apt 3B
[EMAIL PROTECTED]  Forest Hills, NY 11375



---(end of broadcast)---
TIP 6: Have you searched our list archives?

http://www.postgresql.org/search.mpl



[GENERAL] Triggers: options besides compiled code?

1998-07-09 Thread Roland Roberts

I started to look at the triggers documentation and was immediately
dismayed to discover that I would have compile code to create a
trigger.  I have been using the old "rules" mechanism to automatically
put a sequence number into a tuple when inserting new rows.  Are my
choices limited to just (1) compiled code, and (2) the old rules
mechanism?

roland
-- 
Roland B. Roberts
[EMAIL PROTECTED]




Re: [GENERAL] Triggers: options besides compiled code?

1998-07-12 Thread Roland Roberts

> "dej" == Jackson, DeJuan <[EMAIL PROTECTED]> writes:

>> if you insert a new row, isn't the sequence automatically
>> inserted?
>> 
dej> It is if you use table defaults.  (see 'create table', and
dej> 'netval()')

Thanks for the tip; Richard Lynch <[EMAIL PROTECTED]> had sent me the
same information via email.  I was unaware of the "default" clause
which certainly makes this piece easier.

I guess I'm still stuck with writing C-code to get cascading deletes,
but I can probably postpone that requirement for a while

Thanks,

roland
-- 
Roland B. Roberts
[EMAIL PROTECTED]




[GENERAL] PostgreSQL connect options?

1998-08-01 Thread Roland Roberts

Once upon a time, I know I saw an example of using connect options to
specify things like a user name.  I can't find any examples in any of
the references now.  So what are some of the options and how does one
specify them?

roland
-- 
Roland B. Roberts, PhD  Custom Software Solutions
[EMAIL PROTECTED]   101 West 15th St #4NN
   New York, NY 10011




[GENERAL] PHP and keystone (formerly PTS)

1998-08-01 Thread Roland Roberts

This isn't exactly a PostgreSQL question, but...

I've sent e-mail to [EMAIL PROTECTED], the author of Keystone,
about what one needs to do to get Keystone to work with PostgreSQL.  I
have it almost working, and am wondering if anyone here has
successfully used Keystone with PostgreSQL.

What seemed to be holding me up at first was one of two things.  Since
PHP connects from the web server, I had to grant select to nobody on
the tables I was interested in.  Alternately, I could have changed the
connect options to use a different user, but I can't find any
documentation on what connect options are available.

Now I have simple PHP scripts working, but I still can't login to
Keystone.

My questions are:

1. Has anyone gotten Keystone to work with PostgresSQL?

2. Are there any pointers on what one needs to do to use PHP to
   talk to PostgreSQL?

There are really separate issues for me, since I am trying to write my
own applications that use PHP and the browser as an interface to
PostgreSQL.

roland
-- 
Roland B. Roberts, PhD  Custom Software Solutions
[EMAIL PROTECTED]   101 West 15th St #4NN
   New York, NY 10011




Re: [GENERAL] PostgreSQL connect options?

1998-08-01 Thread Roland Roberts

>>>>> "Maarten" == Maarten Boekhold <[EMAIL PROTECTED]> writes:

    Maarten> On Sat, 1 Aug 1998, Roland Roberts wrote:

[...]
Maarten> PQconnectdb("dbname=database user=username password=pwd
Maarten> authtype=password");

This is more-or-less what I was looking for.  Is there someplace the
list of options (i.e., dbname, user, password, etc.) is documented?

I'm actually looking to do this from PHP (in apache).  So the function
I have is pg_connect, which is declared as

int pg_connect(string host, string port, string options, 
   string tty, string dbname); 

So, I'm going to try stuffing the user=username into the options to
see if that does what I hope

roland
-- 
Roland B. Roberts, PhD  Custom Software Solutions
[EMAIL PROTECTED]   101 West 15th St #4NN
   New York, NY 10011




[GENERAL] PostgreSQL catalogues: how to find the primary key?

1998-08-02 Thread Roland Roberts

-BEGIN PGP SIGNED MESSAGE-

I've been trying to get Keystone (http://www.stonekeep.com/keystone/)
up and running.  The PHP script it uses are really oriented to MySQL,
although there is a mostly complete set of PostgreSQL functions
written for it.  One thing missing is a query to find the primary key
on a table.

What catalogues do I need to query to find this?  Is there some
documentation on the catalogues (I didn't find any, but).

On a similar note, I've managed to figure out how to find column
widths but looking at the pg_attribute table and subtracting 4 from
the value of atttypmod for strings, including char().  However, that
was slightly non-obvious.  The "old" PHP scripts looked at the attlen
column which no longer seems to apply...am I doing the right thing
here? 

roland

-BEGIN PGP SIGNATURE-
Version: 2.6.2
Comment: Processed by Mailcrypt 3.4, an Emacs/PGP interface

iQCVAwUBNcUV/eoW38lmvDvNAQH6bQP/SaTCxbntNKsNqW46i7kCxpNN/YOtf0z3
ghLlC4Wh9xy/lLgFh9WOjg/Q7ecdA+jL2BCRVTVlWZG0pOwIgXWBZFAyxiz5dKSG
h47jKI97RZi7C8fjXVY3H3RFnpzBtDduK0fMPoPhqXikvfcL0+LrJ9cBwVFSK4I1
6hTxhGU38hc=
=25uZ
-END PGP SIGNATURE-
-- 
Roland B. Roberts, PhD  Custom Software Solutions
[EMAIL PROTECTED]   101 West 15th St #4NN
   New York, NY 10011