Hi dear colleagues,
I'm trying to pull some platform-specific constants out of my
code by using psql variables, e.g.:
$ psql -v TypeLength=4
# CREATE TYPE tref (
INTERNALLENGTH = :TRefTypeLength,
INPUT = tref_in,
OUTPUT = tref_out,
PASSEDBYVALUE
);
which works fine, but when I need such
recap the problem:
On Mon, 2009-06-15 at 15:28 -0700, J. Greg Davidson wrote:
> Hi dear colleagues,
>
> When I need such a constant in a function
> it is not substituted:
> $ psql -v foo=10
> # create function foo() returns integer as 'select '(:foo) language sql;
&g
ger as :g language sql immutable;
g() can be used in the bodies of other functions where it should
be inline substituted since it's immutable.
I'm concerned as to whether this might break if psql slightly
changes how it it does substitution. The documentation does not
fully specify how substit
RNS xml AS $$
SELECT ( xpath($1,$2,ARRAY(
SELECT ARRAY[ $3[i], $3[i+1] ]
FROM generate_series(1, array_upper($3,1), 2) i
) ) )[1]::xml
$$ LANGUAGE sql;
-- END CODE
Is there any decent way to do this in SQL, or do I need
to write it in a procedural language?
Thanks,
_Gre
Hi Everybody,
I'm having trouble finding any way to build up
XML values from their logical components, e.g.
given an XML element tag, an array of attributes
in some form, and an xml[] array of children I
can't find any SQL function or expression which
would construct the XML element. Surely the
s
Hi fellow PostgreSQL hackers,
I just got burned by the idiomatic loop
documented in the PostgreSQL manual as
Example 39-2. Exceptions with UPDATE/INSERT
I have now replaced this "standard" idiom
with a safer one described below.
What went wrong:
It seems that the table I was either
inserting i
os(name_) VALUES($1);
EXCEPTION
WHEN unique_violation THEN -- another thread?
RAISE NOTICE '% "%" unique_violation', this, $1;
END;
END LOOP;
END;
$$ LANGUAGE plpgsql;
-- end code
_Greg
P.S. Sorry about the excessive underscores!
I've been burned by hav
m_not_from_table()
then I could make things even cleaner, but I don't know
if that's possible.
Here are the omitted definitions needed to make this
simplified example code work:
CREATE DOMAIN foo_reftype AS INTEGER;
CREATE TABLE foos (
ref_ foo_reftype PRIMARY KEY,
name_ text UNI
When PostgreSQL calls a C function I get all kinds of interesting
information in the
struct FunctionCallInfoData
and
struct FmgrInfo
(details at bottom). I was hoping to get the oid of the expected
return type somewhere, but I don't see it. Am I missing something?
I'm trying to av
PostgreSQL functions from C, which looks easier. I want to use the
fastest method possible that will not break with future releases - what
do you advise?
Thanks for your answers to these questions and thanks for the excellent
responses to my earlier questions!
Happy New Year,
_Greg
J. Greg Da
I was caught out today by the non-strict behavior of array_append
causing me to get an undesired result for a COALESCE. My subsequent
attempt to create a STRICT VARIADIC generalization of array_append
led to another surprise. The problem was easily solved, but might
be of interest to others. Per
EXPLAIN ... SELECT foo(...);
kinds of things where foo() calls bar() and I don't see that I can
tell anything about the inline status of either function.
Thanks,
_Greg
J. Greg Davidson
--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscriptio
Hello,
My user-defined types are crashing the PostgreSQL server and I don't
understand why. I've been trying to figure it out on my own for overr
a week. I've cooked what I'm doing down to the essentials and I'm
asking for help. Help: What am I doing wrong?
* Sections of this message:
** Over
13 matches
Mail list logo