[GENERAL] Windows to Linux PostgreSQL Migration

2011-02-01 Thread David Johnston
%PDF-'" message appears. I can think of some possible variations and causes for this but figured before I go running for the cliff I'd see if anyone can at least point me in the right direction. Thank You David Johnston

Re: [GENERAL] Windows to Linux PostgreSQL Migration

2011-02-01 Thread David Johnston
d change my Java code (JDBC) to use the newly default "hex" format that appears to be preferred over the "escape" format. Dave -Original Message- From: Andy Colson [mailto:a...@squeakycode.net] Sent: Tuesday, February 01, 2011 4:59 PM To: David Johnston Cc: pgsql-general

Re: [GENERAL] Select for update with offset interferes with concurrent transactions

2011-02-01 Thread David Johnston
If random sampling is desirable would the following construct limit locking only to the sampled rows? SELECT id FROM tasktable WHERE id IN (SELECT random_id_sample()) FOR UPDATE The "random_id_sample" would supply a configurable group of IDs off of tasktable which the FOR UPDATE would then lock

Re: [GENERAL] Importing/Appending to Existing Table

2011-02-02 Thread David Johnston
You also don't have to import the source files directly into the live table. Instead you could create a "staging" table that has no constraints where you can import everything, do some review and updates, then merge that table over to the live one. Depending on how many files you are dealing with

Re: [GENERAL] Database Design Question

2011-02-02 Thread David Johnston
The main concern to consider is whether there are any shared relationships that the different projects all have (e.g., common logon users). Since you cannot query across different databases if there is shared information then a single database would be preferred. I think the concept you want to c

Re: [GENERAL] Issues with generate_series using integer boundaries

2011-02-03 Thread David Johnston
The proposed generate_series(1,9,-1) behavior seems unusual. I think it should throw a warning if the step direction and the start-end directions do not match. Alternatively, the series generated could go from 9 -> 1 instead of returning an empty series (basically the first two arguments are simp

Re: [GENERAL] how to avoid repeating expensive computation in select

2011-02-03 Thread David Johnston
Is using a pl/pgsql function a viable option. Within or without the use of a function you can create a temporary table to hold the needed intermediate results. You can even use a permanent working table and write functions to perform the needed queries against it. Especially for expensive calcul

Re: [GENERAL] Additional Grants To SuperUser?

2011-02-04 Thread David Johnston
Not to be smart about it but you could just logon as carlos (or a different superuser you create for this purpose) and issue "Create Database xxx" and "Create Role xxx" statements and see whether they work. A superuser should (imo) be able to do everything (including dropping) without any addition

Re: [GENERAL] Remove Role Membership

2011-02-04 Thread David Johnston
It appears from my GUI admin program that: REVOKE group-role FROM user-role; Should do the trick. >From the documentation for "REVOKE": http://www.postgresql.org/docs/9.0/static/sql-revoke.html REVOKE [ ADMIN OPTION FOR ] role_name [, ...] FROM role_name [, ...] [ CASCADE | RESTRICT ]

[GENERAL] 9.0.X FOR UPDATE|SHARE on Sub-Query Causes "cannot extract system attribute from virtual tuple" if Sub-Query Returns Records (BUG)

2011-02-08 Thread David Johnston
I actually posted a more detail posting on this issue but I have a lot of extra information that jumbles things up. More simply if you run any query of the form: SELECT subquerycolumn FROM ( SELECT subquerycolumn FROM table WHERE [condition] FOR UPDATE -- WHERE is optional but obvi

Re: [GENERAL] Storing Media Types

2011-02-09 Thread David Johnston
Photos/Images are binary data and thus should be placed into a "bytea" typed field. As to HOW you would identify and load the binary data that would be depending upon your programming language and user interface. If you are using a traditional programming language you would simply create a parame

Re: [GENERAL] 9.0.X FOR UPDATE|SHARE on Sub-Query Causes "cannot extract system attribute from virtual tuple" if Sub-Query Returns Records (BUG)

2011-02-10 Thread David Johnston
ay, February 09, 2011 11:37 PM To: David Johnston Cc: pgsql-general@postgresql.org Subject: Re: [GENERAL] 9.0.X FOR UPDATE|SHARE on Sub-Query Causes "cannot extract system attribute from virtual tuple" if Sub-Query Returns Records (BUG) "David Johnston" writes: > More simply i

Re: [GENERAL] Auto-Increment in Postgres

2011-02-11 Thread David Johnston
"But this adds the column at the end." - column order in the table definition is unreliable; when you output you should specify the column order yourself. As to populating within a sequence that has missing values that is more trouble than it is worth. If you want to add a column and make i

Re: [GENERAL] Select + Functions + Composite Types: Behavior

2011-02-12 Thread David Johnston
noticed in 9.0.3 David J -Original Message- From: pgsql-general-ow...@postgresql.org [mailto:pgsql-general-ow...@postgresql.org] On Behalf Of Tom Lane Sent: Saturday, February 12, 2011 5:33 PM To: David Johnston Cc: pgsql-general@postgresql.org Subject: Re: [GENERAL] Select + Functions + Compo

Re: [GENERAL] Select + Functions + Composite Types: Behavior

2011-02-12 Thread David Johnston
Tom, BTW, with the quick response you provided (THANKS!) I probably should have pinged the list sooner in my search... David J. -Original Message- From: Tom Lane [mailto:t...@sss.pgh.pa.us] Sent: Saturday, February 12, 2011 5:33 PM To: David Johnston Cc: pgsql-general@postgresql.org

Re: [GENERAL] Select + Functions + Composite Types: Behavior

2011-02-12 Thread David Johnston
Another similar situation that I'll bring here first: I want to do: SELECT createdid, eventresult FROM createvehiclesaleimport() er INTO targetid, evtresult; But this gives a function compilation error: ' "evtresult" is not a scalar variable ' createdid/targeted are boolean eventresult/evtresul

[GENERAL] Select + Functions + Composite Types: Behavior

2011-02-12 Thread David Johnston
Hey, I notice the following behavior but have not seen it documented anywhere. I am curious if: A. I missed the documentation B. Is poorly documented C. It's a bug If I put a function that returns a composite type into the FROM clause of a SELECT query (and it - the function - is the only so

[GENERAL] Revoking Function Execute Privilege

2011-02-14 Thread David Johnston
I've executed the following in a clean database: As postgres/superuser: CREATE ROLE impotent NOLOGIN; CREATE FUNCTION testfunc() RETURNS boolean AS $$ BEGIN RETURN true; END; $$ LANGUAGE 'plpgsql'; REVOKE ALL ON FUNCTION testfunc() FROM impotent; SET ROLE impotent;

Re: [GENERAL] Using Bitmap scan instead of Seq scan

2011-02-14 Thread David Johnston
You cannot ALWAYS do an indexed scan - sometimes the only option for the parser is to do a sequential scan (thus you can say "avoid unless you have to" but you can never truly disable sequential scanning). Given limited knowledge of full-text searching I cannot explain why this specific query is u

[GENERAL] Alter Default Privileges Does Not Work For Functions

2011-02-14 Thread David Johnston
After creating and logging into a new database run this script. The initial ALTER DEFAULT PRIVILEGES should make all users unable to execute functions unless given explicit permissions elsewhere. However, the first call to "testfunc()" succeeds. When I explicitly REVOKE ALL for the specific fun

Re: [GENERAL] Alter Default Privileges Does Not Work For Functions

2011-02-14 Thread David Johnston
g the problem. Thanks again for helping me get my head around some of this stuff. David J -Original Message- From: Tom Lane [mailto:t...@sss.pgh.pa.us] Sent: Monday, February 14, 2011 7:05 PM To: David Johnston Cc: pgsql-general@postgresql.org Subject: Re: [GENERAL] Alter Default Privileges

Re: [GENERAL] database design

2011-02-15 Thread David Johnston
Just curious; is it that you have never designed a multi-branch/company database before or do you have little or no database experience at all? As mentioned, you want to tag these records with the branch primary key and relevant date or dates. The question still remains whether you are dealing

Re: [GENERAL] subset of attributes

2011-02-15 Thread David Johnston
Some context would help but some (possibly relevant) possibilities: 1: If you have relation with 5 attributes you can generate tuples with all 5 attributes OR you can generate tuples with a subset of those attributes. Seems obvious but often these kinds of definitions are. 2: When looking a

Re: [GENERAL] disable triggers using psql

2011-02-16 Thread David Johnston
I may be off-track here but triggers do not enforce referential integrity - constraints do. If you need to disable triggers you can do so via the ALTER TABLE command. The reason I think pg_restore works for you is because when a table is built using pg_restore all the data is loaded into all tabl

Re: [GENERAL] find column name that has under score (_)

2011-02-17 Thread David Johnston
Try just using the string function "position". You'll need to check the documentation or wait for others to determine which specific system views you will need to obtain the column name (if you do not already know that part). position(substring in string) int Non-Zero (or maybe >= 0) indic

Re: [GENERAL] constraining chars for all cols of a table

2011-02-18 Thread David Johnston
Restrict access to the table (for inserts) to a function that does the verification and then executes the insert in addition to any kind of logging and "RAISE"ing you need. If you need to validate existing data I'd probably just do some one-time verifications and updates where required.

Re: [GENERAL] constraining chars for all cols of a table

2011-02-18 Thread David Johnston
8, 2011 4:51 PM To: David Johnston; pgsql-general@postgresql.org Subject: Re: [GENERAL] constraining chars for all cols of a table >>Restrict access to the table (for inserts) to a function that does the verification and then executes the insert in addition to any kind of logging and

Re: [GENERAL] constraining chars for all cols of a table

2011-02-18 Thread David Johnston
into those tables. Whether the application logic CAN be represented in a SQL function is another matter but it is at least something to consider. From: Gauthier, Dave [mailto:dave.gauth...@intel.com] Sent: Friday, February 18, 2011 5:46 PM To: David Johnston; pgsql-general@postgresql.org

Re: [GENERAL] Questions about octal vs. hex for bytea

2011-02-20 Thread David Johnston
Been using bytea heavily through JDBC. In transitioning to 9.0 I've found the need to set the bytea_output parameter but otherwise everything else works the same as it did before. As for storage space concerns I do not know for sure but the numbers cannot be that substantial to warrant changin

Re: [GENERAL] why is there no TRIGGER ON SELECT ?

2011-02-22 Thread David Johnston
Melvin: The proposal is to do something of the form SELECT * FROM selecting_function() And have selecting_function() perform any necessary auditing. I guess this work fairly well - as long as you remember to remove "SELECT" privileges on the wrapped table from everyone and setup SECURI

Re: [GENERAL] Reordering a table

2011-02-22 Thread David Johnston
Something like: SELECT ordered.stamp, nextval('sequence') AS rownumber FROM (SELECT stamp FROM table ORDER BY stamp ASC) ordered Incorporate the ID field and UPDATE as necessary to get the result the way you need it. You are apparently aware that you likely have a design or understanding issue

Re: [GENERAL] EXECUTE of a 'create table' string is not happening

2011-02-22 Thread David Johnston
A little lost but the first thing that stands out is that you are attempting to create an actual table instead of a temporary table. Not sure if that difference is meaningful to the function but procedurally is there a reason to create the permanent table instead of a temporary one? If you do

Re: [GENERAL] regexp match in plpgsql

2011-02-22 Thread David Johnston
You are trying to check the entire string to ensure only the specified character class matches at each position. What you are doing is seeing whether or not there is at least one character class matching value in the tested string. Since you want to check the entire string you should: Anchor

Re: [GENERAL] Finding Errors in .csv Input Data

2011-02-22 Thread David Johnston
Rich, The data and table structure provided do not seem to correlate. Regardless, if you changed the delimiter to "|" from "," it is possible that you converted an embedded "," in one of the textual fields into a "|" when you should not have. For Instance: Value1,value2,"value, with comma",valu

Re: [GENERAL] Finding Errors in .csv Input Data

2011-02-23 Thread David Johnston
Why does your transformed data repeat the first 5 columns out the original CSV? Why do values within a given field end up on different lines (e.g., SIERRA MANOR, 39.44)? Basically, your transform output as presented makes no sense to me; I don't even see how you could import any records into Postg

Re: [GENERAL] Adding a column with constraint

2011-02-24 Thread David Johnston
A column constraint can only reference its own column. Since you are referencing "completed" in the CHECK it implicitly converts the Column constraint into a Table constraint - and table constraints do not reference the name of a column like a column constraint does during name auto-generation. D

Re: [GENERAL] array size

2011-02-24 Thread David Johnston
It may help to specify why you feel that array_upper and array_lower are insufficient for your use. I mean, you could " count( unnest( array ) ) " but whether that is better or worse than array_upper really depends on your needs. David J. From: pgsql-general-ow...@postgresql.org [mailto:pg

[GENERAL] Index Ignored Due To Use Of View

2011-02-24 Thread David Johnston
Hi, I have a query using a view such as: SELECT * FROM taskretrievalwithfiles WHERE ti_id='ti_0r0w2'; The view taskretrievalwithfiles is defined as: SELECT taskinstance.ti_id, lotsofotherstuff FROM taskinstance JOIN store ON taskinstance.s_id=store.s_id JOIN sto

Re: [GENERAL] Index Ignored Due To Use Of View

2011-02-25 Thread David Johnston
lains. David J. -Original Message- From: pgsql-general-ow...@postgresql.org [mailto:pgsql-general-ow...@postgresql.org] On Behalf Of Tom Lane Sent: Friday, February 25, 2011 12:33 AM To: David Johnston Cc: pgsql-general@postgresql.org Subject: Re: [GENERAL] Index Ignored Due To Use Of View

Re: [GENERAL] The scope of sequence

2011-02-25 Thread David Johnston
Create one sequence per owner and write a function/trigger that will check the owner id for the record and call the appropriate nextval(sequence) to get the next value for that owner and replace the id with the generated value. If new owner IDs are going to be generated, however, this will not be

Re: [GENERAL] views and categorized tables

2011-02-26 Thread David Johnston
1) You can attach RULES to a view in order to make it updatable. Consider as an alternative putting INSERT/UPDATE code into FUNCTIONs 2) You can introduce one level of hierarchy into the database by placing tables into SCHEMAs. Make sure to "SET search_path" so that all schemas are listed. You w

Re: [GENERAL] Transactions and ID's generated by triggers

2011-02-27 Thread David Johnston
Using pl/pgsql you can: DECLARE idordinal type; BEGIN INSERT INTO tdir_uris_files RETURNING id_ordinal INTO idordinal; INSERT INTO tdir_uris_files_details (id_ordinal) VALUES (idordinal); END; Similar results are possible in other environments. If you do not have access to "RETURNING"

Re: [GENERAL] Lock ACCESS EXCLUSIVE and Select question !

2011-02-28 Thread David Johnston
As mentioned SELECT FOR UPDATE is likely your best option. As for an algorithm if you can find an airline or sporting event case study those two domains have this problem solved already. Barring that the following comes to mind. Create a record for every "seat" that needs to be sold. You can l

Re: [GENERAL] Issues with imported blobs from Postgres 8 to 9

2011-03-01 Thread David Johnston
Is there a way you can dump the same image in hex format (or even PostgreSQL's own escape format) from both the 8.3.6 and 9.0.X setup (with bytea_escape set to escape) and do a file comparison between the two to at least show that the results are different? As I have not actually ever done this I

Re: [GENERAL] Query should have failed, but didn't?

2011-03-01 Thread David Johnston
This is not a bug; given your test queries whenever you reference “id1” you are ALWAYS referencing the column “id1” in table “test2”. >>test=# select * from test2 where id1 in (select id1 from test1) and charge=70; >> id1 | charge  >>-+ >>  10 |     70 >> (1 row) Hint: Consider the re

Re: [GENERAL] I need your help to get opinions about this situation

2011-03-03 Thread David Johnston
I'll leave the "can/cannot" responses to those more familiar with high-load/use situations but I am curious; what reasons other than cost are leading you to discontinue using your current database engine? With that many entities any migration is likely to be quite challenging even if you restrict

Re: [GENERAL] test data

2011-03-04 Thread David Johnston
You could try online yellow-pages and extract names from the HTML; I did this a long time ago for some reason. There may be copyright issues to consider but if you are using it for internal test data... -Original Message- From: pgsql-general-ow...@postgresql.org [mailto:pgsql-general

[GENERAL] Understanding of LOCK and pg_sleep interaction

2011-03-07 Thread David Johnston
Hi, In trying to setup a test for a LOCK 'table' algorithm I attempt to execute two transactions where the first one issues a pg_sleep(10) while 'table' is locked and the second one attempts LOCK 'table' during the time when the pg_sleep is executing. When pg_sleep() returns in the first trans

Re: [GENERAL] Understanding of LOCK and pg_sleep interaction

2011-03-07 Thread David Johnston
OK, so I try the same scripts with pgAdminIII and they work as expected. Sorry for the noise. David J. -Original Message- From: Tom Lane [mailto:t...@sss.pgh.pa.us] Sent: Monday, March 07, 2011 1:20 PM To: David Johnston Cc: pgsql-general@postgresql.org Subject: Re: [GENERAL

Re: [GENERAL] NULL value vs. DEFAULT value.

2011-03-08 Thread David Johnston
I do not see any NULL exception. A default value is used whenever a specific value for a column is not specified. If whatever is trying to insert into this table is assigning a "NULL" value to a field the DEFAULT no longer applies but the NOT NULL check still does. CREATE TABLE Notnullfi

Re: [GENERAL] Using bytea field...

2011-03-08 Thread David Johnston
Not sure if it is possible directly but have you considered (or you might have to) generating an MD5 hash of the data (possibly after encoding) and then comparing the hashes? For a small image it may not matter but if you plan on making the check with any frequency (and multiple times against t

Re: [GENERAL] Copying data from one table to another - how to specify fields?

2011-03-09 Thread David Johnston
2 Possibilities (assuming there is a single record with name == 'Alex' in the drupal_users table; not counting uid 0) 1. There is a record with username = 'Alex' in the phpbb_users table 2. Username is not UNIQUE within phpbb_users Write a select statement to extract username from phpbb_user for

Re: [GENERAL] Copying data from one table to another - how to specify fields?

2011-03-09 Thread David Johnston
SELECT username, count(username) FROM phpbb_users GROUP BY username HAVING count(username) > 1; If anything shows up then (phpbb_users .username) is not a unique field but you are trying to insert it into one that is (drupal_users.uid) -Original Message- From: pgsql-general-ow...@postgr

Re: [GENERAL] Compare an integer to now() - interval '3 days'

2011-03-11 Thread David Johnston
You need to determine how the integer value in "created" in calculated and massage either it and/or "now()" into the same format so that you can compare and manipulate them. There is likely no simple CAST expression you can use but instead have to perform math operations on the values. Since crea

Re: [GENERAL] Autocommit off - commits/rollbacks

2011-03-14 Thread David Johnston
Set autocommit to "true/on". That will give you the desired behavior of allowing all those things that succeed to remain committed. David J. -Original Message- From: pgsql-general-ow...@postgresql.org [mailto:pgsql-general-ow...@postgresql.org] On Behalf Of Vogt, Michael Sent: Monday, Mar

Re: [GENERAL] PostgreSQL for Holdem Manager could not be installed.

2011-03-15 Thread David Johnston
Depending on whether the vendor or user is expected to install and setup PostgreSQL the issue is that the vendor should be contacting the list and asking for help with one of their users/setups as opposed to the end-user asking directly for help. The end-user shouldn't be expected to have the skil

Re: [GENERAL] triggers and FK cascades

2011-03-17 Thread David Johnston
Don't know if this would work but could you check to see if the corresponding PK exists on A? It may also help to explain why you would want to do such a thing so that someone may be able to provide an alternative solution as opposed to simply responding to a generic feature question. David

Re: [GENERAL] Database Design for Components and Interconnections

2011-03-20 Thread David Johnston
Ray, You seem to have a fairly good understanding of the model you are working with. I'd suggest simply finding some technical SQL resources, install PostgreSQL, and fire away. Learn by doing. When doing the design focus on minimizing the amount of non-key repetition that you model (find and re

Re: [GENERAL] General question

2011-03-23 Thread David Johnston
The main significant advantage that NOT making the primary key also a foreign key is that you can set the foreign key reference to ON DELETE SET NULL. If they are shared this will not work since a primary key cannot be NULL. However, if you are going to do "ON DELETE CASCADE" anyway then the m

Re: [GENERAL] General question

2011-03-23 Thread David Johnston
to account? David J. From: salah jubeh [mailto:s_ju...@yahoo.com] Sent: Wednesday, March 23, 2011 10:29 AM To: David Johnston Cc: pgsql Subject: Re: [GENERAL] General question Dear Johnston, Thanks for the reply, I really get a lot of benefit from it. In my design, I have several

Re: [GENERAL] General question

2011-03-23 Thread David Johnston
: Wednesday, March 23, 2011 11:02 AM To: David Johnston Cc: pgsql Subject: Re: [GENERAL] General question It is a user accounts, which might then become customer accounts, accounting accounts, etc. I will use specialization and generalization concepts in database. I did not complete the design

[GENERAL] DO Statement Body Parameters

2011-03-23 Thread David Johnston
I think I understand what is happening but am curious if something along these lines can be accomplished? Consider the following SQL statement (executed via JDBC against a 9.0.3 installation): DO $$ BEGIN PERFORM someexistingfunction ( ? ); END; $$ It appears that such a format is invalid since J

Re: [GENERAL] Default permissions for CREATE SCHEMA/TABLE?

2011-03-24 Thread David Johnston
Keep in mind if you want to alter the GLOBAL privileges (i.e., the defaults) granted via PUBLIC you MUST NOT specify a schema. >From what I can tell there is no way to associate a default owner different that the one executing the CREATE statement (though some inheritance cases do arise IIRC). Da

Re: [GENERAL] Need help for constructing query

2011-03-25 Thread David Johnston
If you group by a unique value you in effect perform no grouping at all... What you need to do, in a subquery, is find the max(date) over the data you want to group by. Then, in the outer query select the record(s) that match that date. It is in the outer query where you can then add in any add

Re: [GENERAL] Need help for constructing query

2011-03-25 Thread David Johnston
Over complicated or not the solution makes sense and seems to be correct. As described you ended up using a sub-query within the EXCEPT clause in order to return just the most recent sensor reading for each sensor (with the additional range check for min/max). I've never actually used an EXCEPT be

Re: [GENERAL] revoke permissions - not working as expected

2011-03-30 Thread David Johnston
The most important thing to remember about REVOKE is that it can only revoke a permission that was explicitly granted. Every database has GLOBAL permissions not tied to any specific schema and granted to PUBLIC. These permissions are inherited by all ROLES as long as they (the permissions) are in

Re: [GENERAL] Counting records in a child table

2011-03-31 Thread David Johnston
An alternative: SELECT parent.*, COALESCE(child.childcount, 0) AS whatever FROM parent LEFT JOIN (SELECT parentid, count(*) as childcount FROM child GROUP BY parented) child ON (parent.id = child.parentid) You could also do: SELECT parent.*, COALESCE((SELECT count(*) FROM child WHERE child.id =

Re: [GENERAL] Counting records in a child table

2011-03-31 Thread David Johnston
Not fully sure on the syntax of the Window to accomplish the specified goal - and am not sure it would be any cleaner anyway. But, the reason I am responding is how you phrased "...windows only compared groups of records in the same table". When I say: FROM tableA * JOIN tableB I have now effec

Re: [GENERAL] Plpgsql function to compute "every other Friday"

2011-04-04 Thread David Johnston
It is a very simplistic approach since you do not take into account holidays. But if it meets your needs what you want is the modulo operator ( "%"; "mod(x,y)" is the equivalent function ) which performs division but returns only the remainder. N % 14 = [a number between 0 and (14 - 1)] N = 7;

Re: [GENERAL] unique amount more than one table

2011-04-05 Thread David Johnston
You can try restricting all name insertions (on any of the tables) to go through one or more functions that serialize amongst themselves. Basically lock a common table and check the view for the new name before inserting. On Apr 5, 2011, at 18:02, Perry Smith wrote: > I have five tables each

Re: [GENERAL] Using Function returning setof record in JOIN

2011-04-08 Thread David Johnston
I do not know the answer but it isn't that difficult to use trial-and-error to check and see whether the TWO most logical forms would work and then ask for further assistance if they do not. Just pretend you have a view with the same name as your function (though you will need to add the parenthes

Re: [GENERAL] what data type to store fixed size integer?

2011-04-11 Thread David Johnston
the data type does not need any arithmetic operations (as of integers). You arguably do not have a number but simply a string that looks like a number. Other examples are zip-codes and phone-numbers if you ignore symbols. Thus you should probably use an appropriately sized char/varchar.

Re: [GENERAL] what data type to store fixed size integer?

2011-04-12 Thread David Johnston
[mailto:apajooha...@gmail.com] Sent: Tuesday, April 12, 2011 1:32 AM To: David Johnston Cc: pgsql-general@postgresql.org Subject: Re: [GENERAL] what data type to store fixed size integer? @Dave On Mon, Apr 11, 2011 at 9:18 PM, David Johnston wrote: >>>> the data type does not need an

Re: [GENERAL] updating rows which have a common value forconsecutive dates

2011-04-13 Thread David Johnston
If you have the ability to use Window functions you can group (as necessary), order by last_update, and then use rank() to number each test run sequentially. Then you can limit the results to ( rank() <= 2 AND current_status = 'FAILED' ). David J. -Original Message- From: pgsql-gener

Re: [GENERAL] updating rows which have a common value forconsecutive dates

2011-04-13 Thread David Johnston
'15 days' AND rank()=2 ; > ERROR: window function call requires an OVER clause > LINE 1: ... age(now(),last_update) <= INTERVAL '15 days' AND rank()=2 ; > > How do I restrict the results to only show when rank=2 ? > > thanks! > > > On Wed, Apr

Re: [GENERAL] Question regarding DEALLOCATE pdo_stmt_00000001

2014-05-22 Thread David Johnston
> > >> 9.3 - On an idle connection the value of query is the last executed query >> - >> which in this case is some form session cleanup command before returning >> the >> connection to the pool. >> >> > So, it is a normal behavior in Postgres. > > One more thing that bothers me, why this idle con

Re: Re : [GENERAL] Query "top 10 and others"

2014-07-04 Thread David Johnston
> > > with QRY as (select C1.country, C1.state, sum(C1.population) > > from places C1 > > group by 1, 2 > >order by 3 DESC > > limit 10) > > > > select * from QRY > > union > > select 'others' as "country", '' as "state", sum(population) > > from places > > where not exists (select 1 f

Re: [GENERAL] Referencing serial col's sequence for insert

2014-07-22 Thread David Johnston
On Tue, Jul 22, 2014 at 9:46 AM, Anil Menon wrote: > Am a bit confused -which one comes first? > > 1) the 'data'||currval('id01_col1_seq') is parsed first : which means it > takes the current session's currval > 2) then the insert is attempted which causes a sequence.nextval to be > performed whi

Re: [GENERAL] Re: Feature proposal and discussion: full-fledged column/function equivalence

2014-08-01 Thread David Johnston
On Fri, Aug 1, 2014 at 6:22 PM, Chris Travers wrote: > On Fri, Aug 1, 2014 at 12:19 PM, David G Johnston < > david.g.johns...@gmail.com> wrote: > >> Vik Fearing wrote >> >> CREATE testfunction(test) returns int language sql as $$ select 1; $$; >> >> SELECT testfunction FROM test; >> >> >> >> That

Re: [GENERAL] Re: understanding why two nearly identical queries take two different planner routes, one 5s and one 2hr

2014-08-06 Thread David Johnston
On Wed, Aug 6, 2014 at 10:08 AM, Jeff Janes wrote: > On Tue, Aug 5, 2014 at 4:30 PM, David G Johnston < > david.g.johns...@gmail.com> wrote: > >> >> Anyway, you should probably experiment with creating a multi-column index >> instead of allowing PostgreSQL to BitmapAnd them together. Likely the

Re: [GENERAL] Questions on dynamic execution and sqlca

2014-08-06 Thread David Johnston
> > > > > - What are the differences among PL/SQL, PL/PGSQL and pgScript. > > > > The first two are languages you write functions in. pgScript is simply > an > > informal way to group a series of statements together and have them > execute > > within a transaction. > > > > AFAICT, this isn't true

[GENERAL] Re: How can i monitor exactly what (partition) tables are accessed by a query?

2014-09-19 Thread David Johnston
On Friday, September 19, 2014, Alban Hertroys wrote: > On 19 Sep 2014, at 3:50, Robert Nix > > wrote: > > > Thanks, David. > > > > I have read that page many times but clearly I have forgotten this: > > > > • Constraint exclusion only works when the query's WHERE clause > contains constants

Re: [GENERAL] Query optimization

2014-10-29 Thread David Johnston
List preference is to inline post or, at worse, bottom post. Please do not top post. On Wed, Oct 29, 2014 at 11:06 AM, Jorge Arevalo wrote: > Hello David, many thanks for your responses, > > Sorry for not providing the content of the fill_table3_function, but it > just executes 3 insert queries

Re: [GENERAL] Query optimization

2014-10-29 Thread David Johnston
On Wed, Oct 29, 2014 at 11:53 AM, Tom Lane wrote: > Jorge Arevalo writes: > > > This is the result of EXPLAIN ANALYZE > > >QUERY > > PLAN > > >

Re: [GENERAL] Query optimization

2014-10-29 Thread David Johnston
On Wed, Oct 29, 2014 at 12:14 PM, Jorge Arevalo wrote: > > SELECT value1,value2,value3,value4, value5, hstore(ARRAY['field9', > 'field10', 'field11', 'field12', 'field13', 'field14'], ARRAY[field9, > field10, field11, field12, field13, field14]) as metadata, value7, (select > array((select row(f1

Re: [GENERAL] SSL Certificates in Postgres 9.3 and Windows 7

2014-11-09 Thread David Johnston
On Sunday, November 9, 2014, Adrian Klaver wrote: > On 11/09/2014 10:14 AM, David G Johnston wrote: > >> Adrian Klaver-4 wrote >> >>> Thank you for all comments and suggestions. >>> >>> More comments/suggestions will have to wait until the missing pieces are >>> filled in. >>> >> >> I read m

Re: [GENERAL] SSL Certificates in Postgres 9.3 and Windows 7

2014-11-09 Thread David Johnston
Yes, that is what I was referring to. The Nabble.com website showed them. http://postgresql.1045698.n5.nabble.com/SSL-Certificates-in-Postgres-9-3-and-Windows-7-td5826230.html David J. On Sunday, November 9, 2014, Magnus Hagander wrote: > On Sun, Nov 9, 2014 at 11:37 PM, David Johns

Re: [HACKERS] Re: [GENERAL] Performance issue with libpq prepared queries on 9.3 and 9.4

2014-11-13 Thread David Johnston
On Thu, Nov 13, 2014 at 5:47 PM, Tom Lane wrote: > David G Johnston writes: > > Tom Lane-2 wrote > >> In the meantime, I assume that your real data contains a small > percentage > >> of values other than these two? If so, maybe cranking up the statistics > >> target would help. If the planner

Re: [GENERAL] Range type bounds

2014-11-26 Thread David Johnston
> I guess what is confusing to me is the transition between the text mode > and the constructor mode is not clear. In particular the page starts with > examples using the constructor mode but then goes to explanations that > actually apply to the text mode before getting back to explaining the > co

Re: [GENERAL] Range type bounds

2014-11-26 Thread David Johnston
On Wednesday, November 26, 2014, Adrian Klaver wrote: > On 11/26/2014 12:34 PM, David Johnston wrote: > >> >> I guess what is confusing to me is the transition between the text >> mode and the constructor mode is not clear. In particular the page >>

Re: [GENERAL] Converting xml to table with optional elements

2014-11-28 Thread David Johnston
On Fri, Nov 28, 2014 at 4:17 AM, Andrus wrote: > Hi! > > You have to process this in two passes. First pass you create a table of >> documents by unnesting the non-optional >Document elements. Second pass you >> explode each individual row/document on that table into its components. >> > > Thank

Re: [GENERAL] Converting xml to table with optional elements

2014-11-28 Thread David Johnston
On Fri, Nov 28, 2014 at 9:40 AM, Andrus wrote: > Hi! > > Thank you. >>Subquery the xpath expression to unnest it and apply a LIMIT 1 > > UPDATE tbl SET ... = (SELECT xpath( tbl.???[...] ) LIMIT 1) > > I used unnest() : > ​Sorry, I meant to say (SELECT unnest(xpath(tbl.???[...])) LIMIT 1

Re: [GENERAL] Converting xml to table with optional elements

2014-11-28 Thread David Johnston
On Fri, Nov 28, 2014 at 10:47 AM, Andrus wrote: > Hi! > > Thank you. > > Instead of defining an xpath for fields define one that captures the xml >> pertaining to the data that would belong to >> a single record.How to create single xpath or xsl which assigns values to >> all columns in Postgres

Fwd: [GENERAL] Array Comparison

2014-12-05 Thread David Johnston
Please send replies to the list. On Friday, December 5, 2014, Ian Harding > wrote: > > > On Fri, Dec 5, 2014 at 5:37 PM, David G Johnston < > david.g.johns...@gmail.com> wrote: > >> Ian Harding wrote >> > On Fri, Dec 5, 2014 at 4:55 PM, Ian Harding < >> >> > harding.ian@ >> >> > > wrote: >> >> I

Re: FW: [GENERAL] SQL rolling window without aggregation

2014-12-08 Thread David Johnston
On Monday, December 8, 2014, Huang, Suya wrote: > -Original Message- > From: pgsql-general-ow...@postgresql.org [mailto: > pgsql-general-ow...@postgresql.org ] On Behalf Of David G > Johnston > Sent: Monday, December 08, 2014 1:18 PM > To: pgsql-general@postgresql.org > Subject: Re: FW:

Re: [GENERAL] Combining two queries

2014-12-18 Thread David Johnston
On Thu, Dec 18, 2014 at 3:02 PM, Robert DiFalco wrote: > Is the intersect any better than what I originally showed? On the ROW > approach, I'm not sure where the context for that is coming from since it > may not be in the intersection. Consider n1 and n2 are NOT friends but they > have >0 mutual

[GENERAL] psql feature request: --list-conninfo (dump the config info psql would use to connect)

2014-12-22 Thread David Johnston
Hi! When psql (libpq) connects it uses a combination of defaults, environment variables, command line arguments, and possibly a pg_service file to figure out where it is going to connect, and how. Specifying the option "--list-conninfo" as an option would cause psql to simply output all of the va

Re: [GENERAL] Rollback on include error in psql

2014-12-29 Thread David Johnston
On Mon, Dec 29, 2014 at 8:49 AM, Adrian Klaver wrote: > On 12/28/2014 05:04 PM, David G Johnston wrote: > > Adrian Klaver-4 wrote > >> On 12/28/2014 10:06 AM, Viktor Shitkovskiy wrote: > >>> I include my own scripts. Each of them creates some table or makes some > >>> changes to existing tables.

Re: [GENERAL] Rollback on include error in psql

2014-12-29 Thread David Johnston
On Mon, Dec 29, 2014 at 9:39 AM, Adrian Klaver wrote: > On 12/29/2014 07:59 AM, David Johnston wrote: > >> >> Anyway, the third undocumented bug is that --single-transactions gets to >> send its COMMIT even if ON_ERROR_STOP​ >> ​takes hold before the end of the sc

Re: [GENERAL] Rollback on include error in psql

2014-12-29 Thread David Johnston
On Mon, Dec 29, 2014 at 9:49 AM, David Johnston wrote: > On Mon, Dec 29, 2014 at 9:39 AM, Adrian Klaver > wrote: > >> On 12/29/2014 07:59 AM, David Johnston wrote: >> >>> >>> Anyway, the third undocumented bug is that --single-transactions gets to &g

  1   2   3   4   5   6   7   8   9   >