> Hi
>
>
> When I need to solve similar situation, I take a code from plpgsql.
> look on function exec_stmt_block. Similar code is in plpgsql_check
> https://github.com/okbob/plpgsql_check/blob/master/plpgsql_check.c
>
Thanks. Got it sorted!
James
--
Sent via pgsql-general mailing list (pgs
The docs for SPI_execute at http://www.postgresql.org/docs/9.4/static/spi.html
say:
"
Note that if a command invoked via SPI fails, then control will not be returned
to your procedure. Rather, the transaction or subtransaction in which your
procedure executes will be rolled back. (This might se
>
> It might be tempting to use a consumer-grade SSD due to the significant
> cost savings, but the money saved is vapor. They may be OK for a dev
> environment, but you *will* pay in downtime in a production environment.
> Unlike regular hard drives where the difference between consumer and
> ent
I have a query that blows the arguments in pg_proc out:
SELECT pg_proc.oid, UNNEST(pg_proc.proargnames), UNNEST(pg_proc.proargtypes),
UNNEST(pg_proc.proargmodes) FROM pg_proc
And that works great if all arguments are input arguments, but if two are
output arguments, then something unexpected ha
>
> James Harper wrote:
> > The docs say I'm supposed to call BackgroundWorkerInitializeConnection in
> a bgworker and then I can start using spi functions, but they aren't clear on
> if
> I should call SPI_connect too.
> >
> > If I call BackgroundWork
The docs say I'm supposed to call BackgroundWorkerInitializeConnection in a
bgworker and then I can start using spi functions, but they aren't clear on if
I should call SPI_connect too.
If I call BackgroundWorkerInitializeConnection and then SPI_execute I get a
return code of SPI_ERROR_UNCONNEC
>
> James Harper wrote on 03.03.2014 21:10:
> > I'm working on an application to accept TDS (Microsoft SQL Server)
> > connections and proxy them to postgres. MSSQL does things a little
> > differently, for instance in addition to a functions it has stored
> > p
> > I'm building against 9.3 at the moment, and my code is external to the
> > postgres process and using libpq connections, but I noticed that 9.4 allows
> > dynamic backend worker processes which would allow my code to run server
> > side and spawn a process for each TDS connection.
>
> Hm, inte
>
> On Thu, Feb 27, 2014 at 6:23 PM, James Harper
> wrote:
> > I see that I can use PQgetResult to get results from an async query, and
> > this
> allows for multiple results, presumably when the query is like "SELECT 123,
> 456; SELECT 'ABC', 'DEF
I see that I can use PQgetResult to get results from an async query, and this
allows for multiple results, presumably when the query is like "SELECT 123,
456; SELECT 'ABC', 'DEF';". Is there a way for a C function, using SPI, to send
result sets without waiting for completion and returning a pot
Just a minor bug in the documentation -
http://www.postgresql.org/docs/9.3/static/bgworker.html says that bgw_main
takes an argument of void*, but when declared as such gcc -Wall gives a warning
of:
init.c:59:19: warning: assignment from incompatible pointer type [enabled by
default]
worker
> Hello
>
> you should to use a SPI API
>
> http://www.postgresql.org/docs/9.3/static/spi.html
>
> http://www.postgresql.org/docs/9.3/static/spi-spi-exec.html
>
Yep just found it. I obviously didn't google hard enough.
Thanks
James
--
Sent via pgsql-general mailing list (pgsql-general@post
I've googled the docs but I can't seem to make a link as to how to execute
database queries from inside a C function. I'm used to having a PGconn and
using the API around that, but how do I do that from inside a C function (and a
bit later on, a language handler?)
Thanks
James
--
Sent via p
> Did you try it?
>
> postgres=# SELECT '1' UNION SELECT 2;
> ?column?
> --
> 1
> 2
> (2 rows)
>
> Now, if I'd done this it would fail:
>
> postgres=# SELECT '1'::text UNION SELECT 2;
> ERROR: UNION types text and integer cannot be matched
> LINE 1: SELECT '1'::text UNI
>
> I prefer the explicit approach used by Postgres - MYSQL is simpler, but I'd
> say
> simplistic in this area. While it can automate the cating of tpes/catories of
> variable, it doesn't always do it the way I want - so I need to be explicit
> anyway.
>
> In your second use case, which fails -
>
> Interestingly - & i'm curious as to why"
>
> SELECT '1' UNION SELECT 2;
> ?column?
> --
> 1
> 2
> (2 rows)
>
> SELECT '1' UNION SELECT 1;
> ?column?
> --
> 1
> (1 row)
>
>
> I didn't think UNION did an explicit "distinct" - if that is what is
> ha
According to clause 3 on
http://www.postgresql.org/docs/9.3/static/typeconv-union-case.html regarding
union type matching:
3. If the non-unknown inputs are not all of the same type category, fail.
So a query "SELECT 1 UNION SELECT 1.1" works because 1 and 1.1 are of the same
category, and one
>
> James Harper writes:
> > I want to make a float(n) type that emulates the mssql float type. The
> > storage requirements are documented as 4 bytes for 1 <= n <=24, and 8
> > bytes for 25 <= n <= 53.
>
> Haven't we got that already?
>
> r
I want to make a float(n) type that emulates the mssql float type. The storage
requirements are documented as 4 bytes for 1 <= n <=24, and 8 bytes for 25 <= n
<= 53. If I understand correctly, my options for emulating this in postgres are:
1. declare as variable length. Storage is then 8 bytes (
In a postgres C function (CREATE FUNCTION LANGUAGE C), is it possible to get
the OID of a parameter and therefore overload a C function? Is there any other
way of overloading a C function?
Thanks
James
--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to y
I have created a custom type called my_numeric, which is roughly the same as
the existing numeric type. I have declared in, out, typmod_in, and typmod_out
functions. I create a table like:
CREATE TABLE test (col1 my_numeric(6, 3));
And then do \d test and can see that col1 is declared as (6, 3)
>
> You probably should define your domain like this:
>
>CREATE DOMAIN myvarchar varchar(42);
>
That's what I thought, so it won't do what I want. I need to be able to set the
length at the time of declaration.
So suppose I wanted to implement myvarchar in C. In my _in function, how do I
I can create an alias of a type like:
CREATE DOMAIN myvarchar varchar;
But I can't declare a myvarchar with a variable size, eg "mycolumn
myvarchar(42)" and from what I've read this is the way it DOMAIN is supposed to
work so I can't do it that way.
Is there a way to define myvarchar the way I
is it possible to have a function that can return a different type depending on
the parameters? Eg (approximately)
if param = "one" then return 1
if param = "two" then return "2"
if param = "three" then return 3.0
etc
I can't see any variant type
thanks
James
--
Sent via pgsql-general m
Not my application :(
> -Original Message-
> From: Tom Lane [mailto:[EMAIL PROTECTED]
> Sent: Saturday, 11 February 2006 01:59
> To: James Harper
> Cc: pgsql-general@postgresql.org
> Subject: Re: [GENERAL] implicit cast of empty string to timestamp
>
> "Ja
that?
Thanks
James
> -Original Message-
> From: [EMAIL PROTECTED] [mailto:pgsql-general-
> [EMAIL PROTECTED] On Behalf Of James Harper
> Sent: Friday, 10 February 2006 20:23
> To: pgsql-general@postgresql.org
> Subject: [GENERAL] implicit cast of empty string to timestamp
>
> am 10.02.2006, um 20:22:57 +1100 mailte James Harper folgendes:
> > Is there anything I can do to make postgres allow an implicit cast
of an
> > empty string to a timestamp, so that a badly behaved application can
do:
>
> > INSERT INTO SomeTable (timestampfield) VA
Is there anything I can do to make postgres allow an implicit cast of an
empty string to a timestamp, so that a badly behaved application can do:
INSERT INTO SomeTable (timestampfield) VALUES ('')
Where timestampfield is of type typestamp. ?
From what I understand of the 'CREATE CAST' command, I
>
> Martijn van Oosterhout writes:
> > IIRC, the idea of a schema came from Oracle where the schema is the
> > username. If you create a schema with the same name as the user what
> > you describe above works. ie mydb.james.myview is in the james
schema
> > in the mydb database.
>
> Actually tha
Under Microsoft SQL, a fully qualified table name is
db.owner.tablename (well actually, linked_server.db.owner.table, but we
won't go there :)
Under Postgres, you can create schemas to simulate different databases
within the one actual database, but as far as I can tell, the owner does
not contrib
> Hi Fellows,
>
> I'm wondering if in postgres we can insert a tuple into a table that
is
> outside of a database (I'm supossed to be connected to database1 and
want
> to insert a register into a table in database2).
>
> This question is because I want to update a tables into one database
from
>
> On Mon, Feb 06, 2006 at 09:42:22PM +1100, James Harper wrote:
> > I think the answer is no, but can anyone tell me if postgresql
supports
> > the older (pre sql-92?) style outer join syntax, eg:
>
> I think you're referring to some kind of non-standard
> invente
I think the answer is no, but can anyone tell me if postgresql supports
the older (pre sql-92?) style outer join syntax, eg:
SELECT *
FROM a,b
WHERE a.pk *= b.fk
It doesn't appear to support that exact syntax, which suggests it
doesn't know what I'm talking about, but maybe there's a system optio
Is there an API method to be able to execute pl/pgsql (or any other
language) code directly from C?
Eg (please excuse the line wrapping, and the fact that this doesn't
represent a case where this would actually be useful!)
result = PQexecPL("plpgsql", "IF $1 = 'xyzzy" THEN SELECT * FROM fnord
END
> On Tue, Jan 31, 2006 at 10:23:54PM +1100, James Harper wrote:
> > For the libpq interface:
> >
> > I need to be able to know if a column in a result from a query is
> > nullable or not. From reading the documentation it seems that I can
> > obtain the followin
>
> Even if such a query did return a "nullable" flag, plenty of other
> metadata would be absent that might be just as interesting from a
> schema-viewing standpoint (CHECK, PRIMARY KEY, etc.). A better way
> to view the schema is to query the system catalogs or the Information
> Schema.
I now
For the libpq interface:
I need to be able to know if a column in a result from a query is
nullable or not. From reading the documentation it seems that I can
obtain the following information:
. scan all the rows in the result and see if there exists a null value
for each column...
. backtrack the
Is there such a thing as a translator/proxy that can pretend to be a
Microsoft SQL server and proxy all the commands to a PostgreSQL server,
and the results back again? Obviously the purpose of it would be to
allow an application written for MSSQL Server to work with PostgreSQL
without modification
38 matches
Mail list logo