Re: Postgresql 9.5 and Shell scripts/variables vs. C programming/defining a value to be used

From: Poul Kristensen <bcc5226(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, John McKown <john(dot)archie(dot)mckown(at)gmail(dot)com>, PostgreSQL General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Postgresql 9.5 and Shell scripts/variables vs. C programming/defining a value to be used
Date: 2016-11-27 21:56:51
Message-ID: CAAOuvVrbk2eiG+uUbg-MEE3P3gBJ0eizrfLg=hSzJ1iPT-2iAg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Solution:

C is able to compile with an embedded shell script.
So a small C program with an argument being the user passed to the shell
script it succeded succesfully.
I am aware that it could be my question was not specifically relevant to
Postgresql! :)
It took a while to solve. :)

Thanks

Poul

2016-11-23 21:31 GMT+01:00 Poul Kristensen <bcc5226(at)gmail(dot)com>:

> My goal is to grap a user from the OS and and substitute the grapped user
> - to be the owner of the database - in the sql commands
> e.g using shell-script substitution syntax:
> create user ${user} with login;
> create tablespace ${user} location '/path/${user)';
> create database ${user} owner ${user} on tablespace ${user};
> I would be surpriced if this should not be possible using gnu gcc but I
> might be wrong. It is just a question of figurering out way to do this.
> http://zetcode.com/db/postgresqlc/ has an example of how to do this using
> integer as argument on
> the commandline.
> Do you have a hint of the substitution syntax to be used in gnu gcc.
>
> Thanks.
>
> /Poul
>
>
>
> 2016-11-23 16:44 GMT+01:00 Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>:
>
>> "David G. Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> writes:
>> > On Wed, Nov 23, 2016 at 3:46 AM, Poul Kristensen <bcc5226(at)gmail(dot)com>
>> wrote:
>> >> In the postgresql.log I get "select datname from $1".
>>
>> > ​That is expected when you parameterize a query - the query string
>> includes
>> > parameter​s instead of values.
>>
>> It looks like Poul is hoping to use a parameter as a table name,
>> which doesn't work. Parameters can only represent values (constants).
>>
>> regards, tom lane
>>
>
>
>
> --
> Med venlig hilsen / Best regards
> Poul Kristensen
> Linux-OS/Virtualizationexpert and Oracle DBA
>

--
Med venlig hilsen / Best regards
Poul Kristensen
Linux-OS/Virtualizationexpert and Oracle DBA

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Juliano 2016-11-28 11:40:35 Re: pg_dump system catalog
Previous Message Melvin Davidson 2016-11-26 22:17:15 Re: 'pg_ctl restart' does not terminate