Обсуждение: How to create c language in postgresql database. Thanks.
I need to create c language in the postgresql database. I only know to create as follows. Create language c ; Is there anything else I need to do before I create the C language? Thanks. Regards. Grace -- View this message in context: http://postgresql.1045698.n5.nabble.com/How-to-create-c-language-in-postgresql-database-Thanks-tp5712221.html Sent from the PostgreSQL - general mailing list archive at Nabble.com.
On 12/06/2012 17:53, leaf_yxj wrote: > I need to create c language in the postgresql database. I only know > to create as follows. > > Create language c ; > > > Is there anything else I need to do before I create the C language? Hello Grace, C isn't available (AFAIK) as a procedural language; however, you have a wide choice of other languages to choose from - see the docs under "Server programming" for some of them. In fact, C is the language used to write PostgreSQL. Ray. -- Raymond O'Donnell :: Galway :: Ireland rod@iol.ie
leaf_yxj <leaf_yxj@163.com> writes: > I need to create c language in the postgresql database. Why do you think you need to do that? It's built-in. regards, tom lane
On 06/12/12 9:53 AM, leaf_yxj wrote: > I need to create c language in the postgresql database. I only know to > create as follows. > > Create language c ; > to clarify what tom said, you externally compile your C functions into .so/.dll files, then bind them in with CREATE FUNCTION name(args) RETURNS ..... AS 'path/filename' LANGUAGE C see http://www.postgresql.org/docs/current/static/xfunc-c.html -- john r pierce N 37, W 122 santa cruz ca mid-left coast
Hi Tom,
Thanks. You guys are right. I check the database. The C programm is there. ----- but why our application team keep ask me to give them the superuser privileges to create the C function. Should they use the superuser to create the C function. if yes , why they need it?
Thanks.
Regards.
Grace
At 2012-06-13 01:55:52,"Tom Lane" <tgl@sss.pgh.pa.us> wrote: >leaf_yxj <leaf_yxj@163.com> writes: >> I need to create c language in the postgresql database. > >Why do you think you need to do that? It's built-in. > > regards, tom lane
Hi Raymond,
Thanks. You guys are right. I check the database. The C programm is there. ----- but why our application team keep ask me to give them the superuser privileges to create the C function. Should they use the superuser to create the C function. if yes , why they need it?
Thanks.
Regards.
Grace
On 12/06/2012 17:53, leaf_yxj wrote:
> I need to create c language in the postgresql database. I only know
> to create as follows.
>
> Create language c ;
>
>
> Is there anything else I need to do before I create the C language?
Hello Grace,
C isn't available (AFAIK) as a procedural language; however, you have a
wide choice of other languages to choose from - see the docs under
"Server programming" for some of them.
In fact, C is the language used to write PostgreSQL.
Ray.
--
Raymond O'Donnell :: Galway :: Ireland
[hidden email]
--
Sent via pgsql-general mailing list ([hidden email])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-generalIf you reply to this email, your message will be added to the discussion below:http://postgresql.1045698.n5.nabble.com/How-to-create-c-language-in-postgresql-database-Thanks-tp5712221p5712228.html
View this message in context: Re:Re: How to create c language in postgresql database. Thanks.
Sent from the PostgreSQL - general mailing list archive at Nabble.com.
Hi John,
Thanks. You guys are right. I check the database. The C programm is there. ----- but why our application team keep ask me to give them the superuser privileges to create the C function. Should they use the superuser to create the C function. if yes , why they need it?
Thanks.
Regards.
Grace
On 06/12/12 9:53 AM, leaf_yxj wrote:
> I need to create c language in the postgresql database. I only know to
> create as follows.
>
> Create language c ;
>
to clarify what tom said, you externally compile your C functions into
.so/.dll files, then bind them in with CREATE FUNCTION name(args)
RETURNS ..... AS 'path/filename' LANGUAGE C
see http://www.postgresql.org/docs/current/static/xfunc-c.html
--
john r pierce N 37, W 122
santa cruz ca mid-left coast
--
Sent via pgsql-general mailing list ([hidden email])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-generalIf you reply to this email, your message will be added to the discussion below:http://postgresql.1045698.n5.nabble.com/How-to-create-c-language-in-postgresql-database-Thanks-tp5712221p5712238.html
View this message in context: Re:Re: How to create c language in postgresql database. Thanks.
Sent from the PostgreSQL - general mailing list archive at Nabble.com.
Hi Tom, Thanks. You guys are right. I check the database. The C programm is there. ----- but why our application team keep ask me to give them the superuser privileges to create the C function. Should they use the superuser to create the C function. if yes , why they need it? Thanks. Regards. Grace -- View this message in context: http://postgresql.1045698.n5.nabble.com/How-to-create-c-language-in-postgresql-database-Thanks-tp5712221p5712244.html Sent from the PostgreSQL - general mailing list archive at Nabble.com.
On 06/12/12 11:25 AM, leaf_yxj wrote: > Thanks. You guys are right. I check the database. The C programm is > there. ----- but why our application team keep ask me to give them > the superuser privileges to create the C function. Should they use the > superuser to create the C function. if yes , why they need it? yes, only a sql superuser can define a C function, as these have total access to crashing postgres's innards. -- john r pierce N 37, W 122 santa cruz ca mid-left coast
John,
So can I ( the superuser) do it by myself and how can I do it?
Thanks.
Grace
On 06/12/12 11:25 AM, leaf_yxj wrote:
> Thanks. You guys are right. I check the database. The C programm is
> there. ----- but why our application team keep ask me to give them
> the superuser privileges to create the C function. Should they use the
> superuser to create the C function. if yes , why they need it?
yes, only a sql superuser can define a C function, as these have total
access to crashing postgres's innards.
--
john r pierce N 37, W 122
santa cruz ca mid-left coast
--
Sent via pgsql-general mailing list ([hidden email])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-generalIf you reply to this email, your message will be added to the discussion below:http://postgresql.1045698.n5.nabble.com/How-to-create-c-language-in-postgresql-database-Thanks-tp5712221p5712251.html
View this message in context: Re:Re: How to create c language in postgresql database. Thanks.
Sent from the PostgreSQL - general mailing list archive at Nabble.com.
On 06/12/12 12:04 PM, leaf_yxj wrote: > So can I ( the superuser) do it by myself and how can I do it? the devs would give you the .dll/.so file, and a .sql scrap to do the install. you'd put the .so/.dll in an appropriate place, and run the .sql scrap to install it into a given database. -- john r pierce N 37, W 122 santa cruz ca mid-left coast
Hi John,
one more question: so it's one time jobs or it need keep doing.
Thanks.
Grace
On 06/12/12 11:25 AM, leaf_yxj wrote:
> Thanks. You guys are right. I check the database. The C programm is
> there. ----- but why our application team keep ask me to give them
> the superuser privileges to create the C function. Should they use the
> superuser to create the C function. if yes , why they need it?
yes, only a sql superuser can define a C function, as these have total
access to crashing postgres's innards.
--
john r pierce N 37, W 122
santa cruz ca mid-left coast
--
Sent via pgsql-general mailing list ([hidden email])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-generalIf you reply to this email, your message will be added to the discussion below:http://postgresql.1045698.n5.nabble.com/How-to-create-c-language-in-postgresql-database-Thanks-tp5712221p5712251.html
View this message in context: Re:Re: How to create c language in postgresql database. Thanks.
Sent from the PostgreSQL - general mailing list archive at Nabble.com.
On 06/12/12 12:07 PM, leaf_yxj wrote: > one more question: so it's one time jobs or it need keep doing. each time the C function is updated, you would need to DROP FUNCTION / replace binary / CREATE FUNCTION in any database that needs it. and each time you create a new database that needs it, you'd need to CREATE FUNCTION -- john r pierce N 37, W 122 santa cruz ca mid-left coast
Hi John,
Thanks for your quick reply. It's really help me a lot.
1) What's the info in .dll/.so ?
2) .sql scrap is the binary installation file?
3) For the same database, we need update C functions frequently ?
Thanks.
Regards.
Grace
On 06/12/12 12:04 PM, leaf_yxj wrote:
> So can I ( the superuser) do it by myself and how can I do it?
the devs would give you the .dll/.so file, and a .sql scrap to do the
install. you'd put the .so/.dll in an appropriate place, and run the
.sql scrap to install it into a given database.
--
john r pierce N 37, W 122
santa cruz ca mid-left coast
--
Sent via pgsql-general mailing list ([hidden email])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-generalIf you reply to this email, your message will be added to the discussion below:http://postgresql.1045698.n5.nabble.com/How-to-create-c-language-in-postgresql-database-Thanks-tp5712221p5712256.html
View this message in context: Re:Re: How to create c language in postgresql database. Thanks.
Sent from the PostgreSQL - general mailing list archive at Nabble.com.
On 06/12/12 12:22 PM, leaf_yxj wrote: > 1) What's the info in .dll/.so ? thats the binary code compiled and linked from C, windows calls this DLL (Dynamic Link Library), while unix usually calls it SO (Shared Object). Mac OSX has yet another name (dylib or something). > 2) .sql scrap is the binary installation file? the .sql is the CREATE FUNCTION statement mostly. > 3) For the same database, we need update C functions frequently ? you tell me? how often do your programmers change them? -- john r pierce N 37, W 122 santa cruz ca mid-left coast
Hi John,
Thanks for your useful info. I really apprecaite it. I got this problem when the SAS application try to install the scoring model. So I am very confused.
> 1) What's the info in .dll/.so ?
thats the binary code compiled and linked from C, windows calls this
DLL (Dynamic Link Library), while unix usually calls it SO (Shared
Object). Mac OSX has yet another name (dylib or something).
thats the binary code compiled and linked from C, windows calls this
DLL (Dynamic Link Library), while unix usually calls it SO (Shared
Object). Mac OSX has yet another name (dylib or something).
---- Grace comments : this need the superuser privileges on the server to copy those .so ( we are on the linux server) to the postgresql server ?
correct ????
> 2) .sql scrap is the binary installation file?
the .sql is the CREATE FUNCTION statement mostly.
--- Grace comments : we already grant create privileges on the saslib schema. So it means they can this scrap by themselves ???
> 3) For the same database, we need update C functions frequently ?
you tell me? how often do your programmers change them?
---- Grace commends : they tried to SAS to create lot of models. So I amn't sure about this issues. But John, thanks a lot for your answers.
the .sql is the CREATE FUNCTION statement mostly.
--- Grace comments : we already grant create privileges on the saslib schema. So it means they can this scrap by themselves ???
> 3) For the same database, we need update C functions frequently ?
you tell me? how often do your programmers change them?
---- Grace commends : they tried to SAS to create lot of models. So I amn't sure about this issues. But John, thanks a lot for your answers.
Thanks.
Regards.
Grace
On 06/12/12 12:22 PM, leaf_yxj wrote:
> 1) What's the info in .dll/.so ?
thats the binary code compiled and linked from C, windows calls this
DLL (Dynamic Link Library), while unix usually calls it SO (Shared
Object). Mac OSX has yet another name (dylib or something).
> 2) .sql scrap is the binary installation file?
the .sql is the CREATE FUNCTION statement mostly.
> 3) For the same database, we need update C functions frequently ?
you tell me? how often do your programmers change them?
--
john r pierce N 37, W 122
santa cruz ca mid-left coast
--
Sent via pgsql-general mailing list ([hidden email])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-generalIf you reply to this email, your message will be added to the discussion below:http://postgresql.1045698.n5.nabble.com/How-to-create-c-language-in-postgresql-database-Thanks-tp5712221p5712261.html
View this message in context: Re:Re: How to create c language in postgresql database. Thanks.
Sent from the PostgreSQL - general mailing list archive at Nabble.com.
On 06/13/2012 03:35 AM, leaf_yxj wrote:
And to dynamically link them into the PostgreSQL executable to run them.Hi John,Thanks for your useful info. I really apprecaite it. I got this problem when the SAS application try to install the scoring model. So I am very confused.> 1) What's the info in .dll/.so ?
thats the binary code compiled and linked from C, windows calls this
DLL (Dynamic Link Library), while unix usually calls it SO (Shared
Object). Mac OSX has yet another name (dylib or something).---- Grace comments : this need the superuser privileges on the server to copy those .so ( we are on the linux server) to the postgresql server ?correct ????
Most importantly, you have to COMPLTELY AND UTTERLY TRUST YOUR DEV TEAM. If you let them install a C library they've written, you've given them total power over your database, so they can just use their C function to give themselves superuser privs if they want it. This isn't a bad thing; C functions are extremely fast and powerful tools in a database, you just have to trust the person or people who wrote them.
A C library also has much greater opportunity to muck up your database. In particular it can crash database backends very easily. You need to know the people who wrote it are competent and tested it well in a non-production environment.
You need to read about "dlopen" or "LoadLibrary", about dynamic linking, about compilation and shared libraries in C, etc. Right now you don't have the background in how this works to make appropriate decisions; you have to either trust your dev team to do the right thing, or tell them to do what they need to without using a C library and accept that may mean you're stopping them from doing their jobs properly.
> 2) .sql scrap is the binary installation file?
the .sql is the CREATE FUNCTION statement mostly.
--- Grace comments : we already grant create privileges on the saslib schema. So it means they can this scrap by themselves ???
No, you have to be a superuser to install C functions, because they have *total* access to all of PostgreSQL and can bypass all security and authentication completely.
--
Craig Ringer
On Tue, Jun 12, 2012 at 11:47 AM, John R Pierce <pierce@hogranch.com> wrote: > On 06/12/12 11:25 AM, leaf_yxj wrote: >> >> Thanks. You guys are right. I check the database. The C programm is there. >> ----- but why our application team keep ask me to give them the superuser >> privileges to create the C function. Should they use the superuser to create >> the C function. if yes , why they need it? > > > yes, only a sql superuser can define a C function, as these have total > access to crashing postgres's innards. > Not just the innards, but the file system (could be used to overwrite data files), arbitrary system commands, etc...... Best Wishes, Chris Travers
On 06/13/2012 12:45 PM, Chris Travers wrote: > On Tue, Jun 12, 2012 at 11:47 AM, John R Pierce <pierce@hogranch.com> wrote: >> On 06/12/12 11:25 AM, leaf_yxj wrote: >>> Thanks. You guys are right. I check the database. The C programm is there. >>> ----- but why our application team keep ask me to give them the superuser >>> privileges to create the C function. Should they use the superuser to create >>> the C function. if yes , why they need it? >> >> yes, only a sql superuser can define a C function, as these have total >> access to crashing postgres's innards. >> > Not just the innards, but the file system (could be used to overwrite > data files), arbitrary system commands, etc...... Hopefully not arbitrary system commands, in that I really hope nobody's nuts enough to run PostgreSQL as root or with write access to its own binaries. The data files are fair game, though, and replacement/modification of commands is probably possible in weaker installations. -- Craig Ringer
On Wed, Jun 13, 2012 at 12:19 AM, Craig Ringer <ringerc@ringerc.id.au> wrote: > On 06/13/2012 12:45 PM, Chris Travers wrote: >> >> On Tue, Jun 12, 2012 at 11:47 AM, John R Pierce <pierce@hogranch.com> >> wrote: >>> >>> On 06/12/12 11:25 AM, leaf_yxj wrote: >>>> >>>> Thanks. You guys are right. I check the database. The C programm is >>>> there. >>>> ----- but why our application team keep ask me to give them the >>>> superuser >>>> privileges to create the C function. Should they use the superuser to >>>> create >>>> the C function. if yes , why they need it? >>> >>> >>> yes, only a sql superuser can define a C function, as these have total >>> access to crashing postgres's innards. >>> >> Not just the innards, but the file system (could be used to overwrite >> data files), arbitrary system commands, etc...... > > Hopefully not arbitrary system commands, in that I really hope nobody's nuts > enough to run PostgreSQL as root or with write access to its own binaries. > The data files are fair game, though, and replacement/modification of > commands is probably possible in weaker installations. Maybe not as arbitrary as it would as root, but at least arbitrary in the sense of "able to do or access anything that the system will let the Postgres process access." That means all binaries an ordinary user can access and all system calls that don't require root unless you lock things down using something like SELinux..... Best Wishes, Chris Travers
Hi Chris and Guys,
Thanks for your answers. I really appreciate it. Although I don't understand the whole things you guys mentioned to me. I think maybe I should do it by myself. I need to do a test. If there is any good guide/white paper, please give me a link for me to study.
Thanks.
Regards.
Grace
On Wed, Jun 13, 2012 at 12:19 AM, Craig Ringer <[hidden email]> wrote:Maybe not as arbitrary as it would as root, but at least arbitrary in
> On 06/13/2012 12:45 PM, Chris Travers wrote:
>>
>> On Tue, Jun 12, 2012 at 11:47 AM, John R Pierce <[hidden email]>
>> wrote:
>>>
>>> On 06/12/12 11:25 AM, leaf_yxj wrote:
>>>>
>>>> Thanks. You guys are right. I check the database. The C programm is
>>>> there.
>>>> ----- but why our application team keep ask me to give them the
>>>> superuser
>>>> privileges to create the C function. Should they use the superuser to
>>>> create
>>>> the C function. if yes , why they need it?
>>>
>>>
>>> yes, only a sql superuser can define a C function, as these have total
>>> access to crashing postgres's innards.
>>>
>> Not just the innards, but the file system (could be used to overwrite
>> data files), arbitrary system commands, etc......
>
> Hopefully not arbitrary system commands, in that I really hope nobody's nuts
> enough to run PostgreSQL as root or with write access to its own binaries.
> The data files are fair game, though, and replacement/modification of
> commands is probably possible in weaker installations.
the sense of "able to do or access anything that the system will let
the Postgres process access." That means all binaries an ordinary
user can access and all system calls that don't require root unless
you lock things down using something like SELinux.....
Best Wishes,
Chris Travers
--
Sent via pgsql-general mailing list ([hidden email])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-generalIf you reply to this email, your message will be added to the discussion below:http://postgresql.1045698.n5.nabble.com/How-to-create-c-language-in-postgresql-database-Thanks-tp5712221p5712359.html
View this message in context: Re:Re: How to create c language in postgresql database. Thanks.
Sent from the PostgreSQL - general mailing list archive at Nabble.com.
leaf_yxj wrote: > Thanks for your answers. I really appreciate it. Although I don't understand the whole things you guys > mentioned to me. I think maybe I should do it by myself. I need to do a test. If there is any good > guide/white paper, please give me a link for me to study. I think the documentation is quite good and comprehensive: http://www.postgresql.org/docs/current/static/xfunc-c.html If you look for samples, the contrib modules will serve. Yours, Laurenz Albe
Hi Albe,
Thanks. I will study it.
Regards.
Grace
At 2012-06-14 15:33:07,"Albe Laurenz" <laurenz.albe@wien.gv.at> wrote: >leaf_yxj wrote: >> Thanks for your answers. I really appreciate it. Although I don't >understand the whole things you guys >> mentioned to me. I think maybe I should do it by myself. I need to do >a test. If there is any good >> guide/white paper, please give me a link for me to study. > >I think the documentation is quite good and comprehensive: > >http://www.postgresql.org/docs/current/static/xfunc-c.html > >If you look for samples, the contrib modules will serve. > >Yours, >Laurenz Albe