PostgreSQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesPostgreSQL Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 4th, 2003, 08:40 AM
rod k rod k is offline
Apprentice Deity
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Jul 1999
Location: Niagara Falls (On the wrong side of the gorge)
Posts: 3,237 rod k User rank is Private First Class (20 - 50 Reputation Level)rod k User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 m 8 sec
Reputation Power: 13
Send a message via AIM to rod k
Thumbs up plphp

plphp has just been released for those of you who are interested. I haven't tried it myself yet, as I'm having problems building it under FreeBSD but for anyone running Linux they have binaries available.
__________________
FSBO (For Sale By Owner) Realty

Reply With Quote
  #2  
Old August 4th, 2003, 09:17 AM
Jabol Jabol is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Poland
Posts: 57 Jabol User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 28 m 57 sec
Reputation Power: 6
hi,
I was running and I must say that it rocks!
But I'm a bit disappointed as well. I cannot build my own version ( or at least don't know how ) and there is no documentation. It all works till I'm not creating functions using arguments and I dunno why becouse there's no docs.
I wish there will be a day in which it'll be bundled into postgres main distribution and I'll be able to build it with my own php version without any problems.

Reply With Quote
  #3  
Old August 4th, 2003, 09:53 AM
rod k rod k is offline
Apprentice Deity
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Jul 1999
Location: Niagara Falls (On the wrong side of the gorge)
Posts: 3,237 rod k User rank is Private First Class (20 - 50 Reputation Level)rod k User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 m 8 sec
Reputation Power: 13
Send a message via AIM to rod k
Quote:
there is no documentation
It's still beta... I'm sure docs are forthcoming

Quote:
It all works till I'm not creating functions using arguments
Are you saying functions with arguments don't work or functions without arguments?

Reply With Quote
  #4  
Old August 4th, 2003, 09:58 AM
Jabol Jabol is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Poland
Posts: 57 Jabol User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 28 m 57 sec
Reputation Power: 6
I mean functions with arguments, but mayby it's just that I dunno how to use tham. I tried $argv[1] and $1 and neither worked

Reply With Quote
  #5  
Old August 4th, 2003, 10:11 AM
rod k rod k is offline
Apprentice Deity
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Jul 1999
Location: Niagara Falls (On the wrong side of the gorge)
Posts: 3,237 rod k User rank is Private First Class (20 - 50 Reputation Level)rod k User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 m 8 sec
Reputation Power: 13
Send a message via AIM to rod k
Hmm, did you try func_get_arg() or fung_get_args()?

Reply With Quote
  #6  
Old August 4th, 2003, 10:19 AM
Jabol Jabol is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Poland
Posts: 57 Jabol User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 28 m 57 sec
Reputation Power: 6
hmm... no. I'll try it soon.

Reply With Quote
  #7  
Old August 4th, 2003, 10:34 AM
rycamor rycamor is offline
Gödelian monster
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jul 1999
Location: Pembroke Pines, Florida, USA
Posts: 2,300 rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 3 Days 3 h 12 m 27 sec
Reputation Power: 56
Thanks rod; this is some fairly rocking news. I hadn't expected this to happen so soon. Of course, I too will reserve judgement until I can run it on FreeBSD .
__________________
The real n-tier system:

FreeBSD -> PostgreSQL -> [any_language] -> Apache -> Mozilla/XUL

Amazon wishlist -- rycamor (at) gmail.com

Reply With Quote
  #8  
Old August 4th, 2003, 10:41 AM
rod k rod k is offline
Apprentice Deity
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Jul 1999
Location: Niagara Falls (On the wrong side of the gorge)
Posts: 3,237 rod k User rank is Private First Class (20 - 50 Reputation Level)rod k User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 m 8 sec
Reputation Power: 13
Send a message via AIM to rod k
Hehe, I'm so itchin' to try it that I'm thinking about installing slackware on one of my boxes....

Reply With Quote
  #9  
Old August 4th, 2003, 10:46 AM
rycamor rycamor is offline
Gödelian monster
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jul 1999
Location: Pembroke Pines, Florida, USA
Posts: 2,300 rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 3 Days 3 h 12 m 27 sec
Reputation Power: 56
Quote:
Originally posted by rod k
Hehe, I'm so itchin' to try it that I'm thinking about installing slackware on one of my boxes....

Slackware isn't bad... I use it for one of my desktops. The only problem is... sigh... nothing remotely like the FreeBSD ports system. Slackware + ports would be a cool Linux distro. Oops... the OT meter is dipping into the red.

Reply With Quote
  #10  
Old August 4th, 2003, 04:11 PM
bcyde's Avatar
bcyde bcyde is offline
Me likey breadsticks...
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jan 2003
Location: Los Angeles
Posts: 1,189 bcyde User rank is Sergeant (500 - 2000 Reputation Level)bcyde User rank is Sergeant (500 - 2000 Reputation Level)bcyde User rank is Sergeant (500 - 2000 Reputation Level)bcyde User rank is Sergeant (500 - 2000 Reputation Level)bcyde User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 3 Days 1 h 12 m 58 sec
Reputation Power: 12
Send a message via AIM to bcyde Send a message via Yahoo to bcyde
So when this does come out and starts to get polished what's going to be the PG procedural language of choice? A few postings in the last couple of weeks on the PG mailing list led me to believe that plpgsql development is kind of slow at the moment since there's no dedicated developer on it and for certain functions I've seen people recommend plctl and/or plperl over plpgsql.

I haven't had to do much with my own user defined functions and only experimented with a few simple ones in plpgsql but will there eventually be 1 language of choice or is it going to be "use what you're familiar", or "this language is good at this, but can't do this" sort of thing?

-b

Reply With Quote
  #11  
Old August 4th, 2003, 04:46 PM
rod k rod k is offline
Apprentice Deity
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Jul 1999
Location: Niagara Falls (On the wrong side of the gorge)
Posts: 3,237 rod k User rank is Private First Class (20 - 50 Reputation Level)rod k User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 m 8 sec
Reputation Power: 13
Send a message via AIM to rod k
Well, plpgsql is only good for internal DB stuff. If you want to write "untrusted" procedures (e.g. sending emails) then you need to use something else. I think for most applications plphp will work fine, tho I could see plperl being superior in certain situations. I'm much better with PHP than I am with Perl, so I'm really looking forward to this.


BTW, I've just about got plphp to build on FreeBSD 4.8 I'll zip the .so file and attach it here when I get it completed.

Reply With Quote
  #12  
Old August 4th, 2003, 05:20 PM
rycamor rycamor is offline
Gödelian monster
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jul 1999
Location: Pembroke Pines, Florida, USA
Posts: 2,300 rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 3 Days 3 h 12 m 27 sec
Reputation Power: 56
bcyde raises a good point. I have to admit that I have some mixed feelings about PostgreSQL's procedural approach. While I think its great that we can do procedures in many languages, I hope the team doesn't lose focus on making Pl/PgSQL a bulletproof tank of a language .

It seems to me that most database procedural languages are rather on the strict side, for obvious reasons (no implicit type conversion, etc...). Also, they tend to be more like Functional/declarative languages, deriving some ancestry from LISP, etc... I consider this to be a Good Thing, in the sense that a procedural language should be about supporting business logic. Business logic is the sort of thing that should be "ironclad". Also, IMHO, the strict methods used allow the system to do more optimizing for speed and stability, but mainly allow the programmer to focus more on logic and less on such "manual" things as incrementing variables in loops, etc... Ask anyone who uses PL/SQL for Oracle, and they would wonder why on earth you would need another language for database back-end logic.

Languages like PHP and Perl tend to be a lot more flexible in how you approach variables, types, and structure, and allow you to be in general just a little more arbitrary about how you do things. I would say that PHP and Perl should be used for things that are harder to do in the main procedural language. Generally, I'm thinking of tasks that are more "un-database-like" and involve more messy details. Triggers that send emails or connect to the filesystem in some way, etc... are just a few examples. Also, procedures that play with strings, regular expressions, etc... might be more suited to Perl/PHP type languages.

So, I think there should be two major areas of concern for stored procedures:
1. core business logic, more appropriate for Pl/PgSQL, etc...
2. messy details, more suited to Perl and PHP, and untrusted environments, as rod mentions.

Not sure about languages like TCL or Python, though. Python is more of a functional language, and also allows for more strictness of typing, etc... so maybe it falls somewhere in between. TCL is supposedly somewhat functional, but I know very little about it.

So, given this, I believe I will still be attempting most of my serious procedures in Pl/PgSQL, but I will be playing around with PHP for some of the more "fun" areas of stored procedures. I hope the PostgreSQL developers don't give up on advancing Pl/PgSQL. I think what Pl/PgSQL needs is more power in the area of expressing abstract logic, and in the ability to interact more smoothly with other procedures.

Mainly, though, I think the whole procedural interface could use a little more thought, in terms of how the procedural system interacts with the rest of the database. Apparently (and I say this without extensive Oracle experience) it is much more complete and seamless in Oracle, with more logical control over parameters, naming, nested transactions, etc...

On a final note, here is a current list of procedural languages available PostgreSQL:

1. SQL
2. Pl/PgSQL
3. PL/R -- for heavy-duty statistical computing (still in development)
4. C -- when you really need nuts-n-bolts
5. Java (still in development)
6. Perl
7. Python
8. PHP (still in development)
9. TCL

It'll be interesting to see where all this leads...

Reply With Quote
  #13  
Old August 4th, 2003, 06:24 PM
Jabol Jabol is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Poland
Posts: 57 Jabol User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 28 m 57 sec
Reputation Power: 6
Yeah, you're right.
The main application should be build using sql/plpgsql only. Another languages, like php or perl (or the others) may be useful while doing something out of database, for example sending email, reading file or making a net connection. This is something that you cannot do using sql/plpgsql.
I've never used and never needed any another language with postgresql so I agree with you.

Reply With Quote
  #14  
Old August 4th, 2003, 09:46 PM
rod k rod k is offline
Apprentice Deity
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Jul 1999
Location: Niagara Falls (On the wrong side of the gorge)
Posts: 3,237 rod k User rank is Private First Class (20 - 50 Reputation Level)rod k User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 m 8 sec
Reputation Power: 13
Send a message via AIM to rod k
Jabol,

Per a post on the plphp mailing list, it looks like the function arguments are passed as $arg0, $arg1, $arg2, ... $argn

Reply With Quote
  #15  
Old August 4th, 2003, 10:12 PM
rycamor rycamor is offline
Gödelian monster
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jul 1999
Location: Pembroke Pines, Florida, USA
Posts: 2,300 rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 3 Days 3 h 12 m 27 sec
Reputation Power: 56
Quote:
Originally posted by rod k
Jabol,

Per a post on the plphp mailing list, it looks like the function arguments are passed as $arg0, $arg1, $arg2, ... $argn


Yeah, that would make sense, since PHP cannot have a variable name start with a number. But, I would kind of prefer something like $arg[0] ... $arg[n].

One thing I really like about PHP is the nice array-manipulation methods you get. I wonder how well this will work with PostgreSQL's array type, and functions dealing with arrays.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesPostgreSQL Help > plphp